โ† All PCEP Flashcard Decks

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
  1. What is the output of `len('Python 3')`?

    Answer: 8

    `len()` counts all characters including spaces, so 'Python 3' has 8 characters.

  2. 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`.

  3. What does `'Python'.find('th')` return?

    Answer: 2

    `find()` returns the index of the first occurrence of the substring; 'th' starts at index 2.

  4. 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.

  5. What does `'Hello World'.lower()` return?

    Answer: hello world

    `lower()` converts every character in the string to lowercase.

  6. 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.