PCEP String Operations and Methods Flashcards
6 cards from real PCEP practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.
Read the first 6 PCEP String Operations and Methods flashcards as text
What is the output of `len('Python 3')`?
Answer: 8
`len()` counts all characters including spaces, so 'Python 3' has 8 characters.
Which method replaces all occurrences of a substring in a string?
Answer: replace()
`replace(old, new)` returns a new string with all occurrences of `old` replaced by `new`.
What does `'Python'.find('th')` return?
Answer: 2
`find()` returns the index of the first occurrence of the substring; 'th' starts at index 2.
What is the output of `'-'.join(['a', 'b', 'c'])`?
Answer: a-b-c
`join()` concatenates list elements with the calling string as a separator between each item.
What does `'Hello World'.lower()` return?
Answer: hello world
`lower()` converts every character in the string to lowercase.
Which escape sequence represents a newline character in a Python string?
Answer: \n
`\n` is the escape sequence for a newline, which moves output to the next line.
How this page was made: written with AI tools and published by Nathan Beja, founder of Practice Test Geeks, who is responsible for its content. Exam facts are checked against the official sources listed below. Not reviewed by a subject-matter expert. Editorial policy
Sources & references
Exam facts on this page (fees, format, dates, passing scores) are checked against these official sources; the date is our last check. Editorial policy
- pythoninstitute.org — Fees, exam format, passing score, retake fee, score release, time limit, score validity, test delivery, eligibility, retake policy · verified Oct 2026