AdaptEd
Pod · look-only preview

Mastering Strings: Indexing, Slicing, and Formatting

Grade 5 Computer Science TEKS PY.3A 4 slides · 11 questions
Shared by Ochoa
Sign in to make a copy
Teachers: your copy includes the answer key.
Use with my class
No account needed. You get a link for students and a private page with their scores.
The answer key isn't shown here. Nothing you do on this page is saved or graded.
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?

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

Pick 1 Correct Answer

Which statement correctly describes how to get the letter 'e' from the string "hello"?

Choose the one correct answer.

Slide 2

Slicing and Using String Methods with Python Code

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

Code PYTHON

Write a Python print statement that outputs the substring 'thon' from the string "python" using slicing.

Print the substring 'thon' by slicing the string "python". Use the correct start and end indexes.
7/100 characters Waiting for input
Slide 3

Combining and Formatting Strings for Cool Outputs

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

Select 2 Correct Answers

Which of the following are correct ways to join or format strings in Python? (Select all that apply.)

Click all the correct answers — there are 2 right options.

0 selected
Check for understanding

Solo Run: String Manipulation Practice

Pick 1 Correct Answer

Which escape character makes text start on a new line in Python strings?

Choose the one correct answer.

Pick 1 Correct Answer

Which of these Python code lines correctly access the third letter in the string "banana"?

Choose the one correct answer.

Code PYTHON

Write Python code to print the substring 'cat' from the string "concatenate" using slicing.

Print 'cat' by slicing the string "concatenate" using correct start and end indexes.
7/100 characters Waiting for input
Select 2 Correct Answers

Select all the valid Python string methods that can change " Hello " to "HELLO" without spaces.

Click all the correct answers — there are 2 right options.

0 selected
Select 2 Correct Answers

Which of these are correct ways to combine the variable name = 'Jill' with the greeting 'Hi' using Python?

Click all the correct answers — there are 2 right options.

0 selected
Exit check

Show What You Know: Mastering Strings

Pick 1 Correct Answer

Which Python string methods would correctly turn " hello world " into "HELLO WORLD" without extra spaces?

Choose the one correct answer.

Matching

Match each term with its correct definition.

Drag a term onto its definition, or click one item from each column to match them.

Terms
Concatenation
Slicing
Indexing
Escape character \n
Definitions
Accessing a single character by position in a string
Extracting a portion of a string using start and end positions
A special code that creates a new line in a string
Joining two or more strings together using +
0 of 4 matched
Sorting

Put these steps in the correct order to extract and format the first name from the string " Amy Johnson ":

Drag and drop the items to put them in the correct order.

First / Top Last / Bottom
  • Use strip() to remove extra spaces
  • Print the final formatted name
  • Use upper() to capitalize the letters
  • Slice the string to get the first 3 letters