โ† 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 `'Python'[1:4]`?

    Answer: yth

    Slicing `[1:4]` extracts characters at indices 1, 2, and 3, giving 'yth'.

  2. Which string method returns `True` if all characters in the string are alphabetic?

    Answer: isalpha()

    `isalpha()` returns `True` only when every character in the string is a letter.

  3. What does `'hello'.upper()` return?

    Answer: HELLO

    The `upper()` method converts all characters in the string to uppercase.

  4. What is the result of `' hello '.strip()`?

    Answer: hello

    `strip()` removes leading and trailing whitespace from a string.

  5. Which operator is used to repeat a string in Python?

    Answer: *

    The `*` operator repeats a string a given number of times, e.g., `'ab' * 3` gives `'ababab'`.

  6. What does `'apple,banana,cherry'.split(',')` return?

    Answer: ['apple', 'banana', 'cherry']

    `split(',')` breaks the string at each comma and returns a list of the resulting substrings.