Opening
🤔 What Do You Think?

- Colorful illustration of the word 'HELLO' with each letter highlighted separately as if in boxes, showing the idea of individual characters.
Slide 1
What Is a String and How Do We Access Its Letters?
- A string is a sequence of characters enclosed in quotes, like "hello" or "123".
- Each character in a string has a position called an index, starting at 0 for the first letter.
- You can get a single letter by using its index in square brackets; for example, "hello"[1] is 'e'.
- string
- — A sequence of letters or characters inside quotes.
- index
- — The position number of a character in a string, starting at 0.
- square brackets
- — Symbols [ ] used to get specific characters from a string.
Check for understanding
Check Your Understanding
Slide 2
Slicing and Using String Methods with Python Code
- Slicing lets you get a part of a string by specifying start and end positions, like name[0:3] gets the first three letters.
- Common string methods include upper() to make letters uppercase and strip() to remove spaces.
- Example Python code: print("python"[1:4]) outputs 'yth', and print(" hello ".strip()) outputs 'hello'.
- Slicing
- — Getting part of a string using start and end positions.
- upper()
- — A method that changes letters to uppercase.
- strip()
- — A method that removes spaces from the start and end of a string.
Check for understanding
Check Your Understanding
Slide 3
Combining and Formatting Strings for Cool Outputs
- You can put strings together using concatenation with the + symbol, like 'Hello, ' + 'world!' = 'Hello, world!'.
- String formatting lets you insert values neatly using f-strings, such as name = 'Amy'; print(f'Hi, {name}!') outputs 'Hi, Amy!'.
- Escape characters like \n create new lines inside strings, making text easier to read.
- concatenation
- — Joining two or more strings using the + sign.
- f-strings
- — Strings that insert variables inside curly braces {}.
- escape characters
- — Special codes like \n to add new lines or tabs in strings.
Check for understanding
Check Your Understanding
Check for understanding
Solo Run: String Manipulation Practice
Exit check