Skip to main content
By the end of this module you can do everything below. The objectives and their wording come from the official PCEP-30-03 syllabus.

3.5.1 Construct strings and access their contents

  • Create strings using single quotation marks, double quotation marks, and triple quotation marks.
  • Use escape sequences introduced by the backslash character.
  • Include quotation marks and apostrophes inside string literals.
  • Create multiline strings.
  • Access characters using positive and negative indexes.
  • Extract substrings using slicing.
  • Use slice start, stop, and step values with strings.
  • Explain string immutability.
  • Determine the length of a string using the len() function.
  • Use the in and not in operators to test whether a substring is present.

3.5.2 Process and transform strings

  • Change letter case using lower(), upper(), capitalize(), title(), and swapcase().
  • Search for characters or substrings using find().
  • Split strings into substrings using split().
  • Join multiple strings using join().
  • Remove whitespace or selected characters from string boundaries using strip(), lstrip(), and rstrip().
  • Replace selected characters or substrings using replace().
  • Recognize that string methods return new strings rather than modifying the original string.

3.5.3 Format values as strings

  • Construct formatted string literals using f-strings.
  • Insert variables and expressions into f-string replacement fields enclosed in {}.
  • Recognize basic formatting performed using the format() method.
  • Recognize basic legacy string formatting performed using the % operator.