

Strings in Python
Presentation
•
Computers
•
8th Grade
•
Practice Problem
•
Medium
Klea h
Used 3+ times
FREE Resource
9 Slides • 12 Questions
1
PYTHON STRINGS
By Klea h
2
Strings in python are surrounded by either single quotation marks, or double quotation marks.
'hello' is the same as "hello".
You can assign a multiline string to a variable by using TRIPLE quotes.
''' Lorem ipsum dolor sit amet,
ut labore et dolore magna aliqua.'''
3
Multiple Choice
Which of the following is a valid way to define a string in Python?
greeting = 'Hi there'
greeting = "Hi there"
greeting = '''Hi there'''
All of the above
4
Multiple Choice
What is the correct way to create a multiline string in Python?
B) note = '''Line1 Line2 Line3'''
C)
D) note = "Line1 Line2 Line3"
note = '''Line1
Line2
Line3'''
note = "Line1
Line2
Line3"
note = 'Line1
Line2
Line3'
I have no Idea
5
Square brackets can be used to access elements of the string.
The first character in Python has the position 0
a = "PYTHON"
print(a[1])
RESULT: Y
6
Multiple Choice
What will this print?
word = "Computer"
print(word[3])
p
u
C
7
Multiple Choice
What is the index of the first character in a string?
It depends on the user
8
To get the length of a string, use the len() function.
a = "Hello, World!"
print(len(a))
RESULT: 13
9
Multiple Choice
Which function is used to find how many characters a string has?
length
len()
length()
len
10
Multiple Choice
What is the output of the following code?
msg = "Good morning"
print(len(msg))
error
11
Check String
To check if a certain phrase or character is present in a string, we use the keyword in.
txt = "The best things in life are free!"
print("free" in txt)
RESULT: True
To check if a certain phrase or character is NOT present in a string, we can use the keyword not in.
txt = "The best things in life are free!"
print("expensive" not in txt)
RESULT: True
12
Multiple Choice
What does the following code return?
sentence = "Coding is fun!"
print("fun" in sentence)
13
Multiple Choice
What will this return?
text = "Apples are red"
print("green" not in text)
14
Slicing
You can return a range of characters by using the slice syntax.
Specify the start index and the end index, separated by a colon, to return a part of the string.
b = "Computer Lab"
print(b[2:5])
RESULT: mpu
15
Slice From the Start
By leaving out the start index, the range will start at the first character:
b = "Hello, World!"
print(b[:5]) -> character in index 5 is NOT included
Slice To the End
By leaving out the end index, the range will go to the end:
b = "Hello, World!"
print(b[2:]) --> starting from the character in index 2 until the end
16
Negative Indexing
Use negative indexes to start the slice from the end of the string:
From: "Y" in "World!" (position -5)
To, but not included: "O" in "World!" (position -2):
b = "PYTHON"
print(b[-5:-2])
17
Fill in the Blanks
18
Fill in the Blanks
19
Python has a set of built-in methods that you can use on strings.
Note: All string methods return new values.
They do not change the original string.
The upper() method returns the string in upper case:
print(a.upper())
The lower() method returns the string in lower case:
print(a.lower())
The strip() method removes any whitespace from the beginning or the end:
print(a.strip())
# returns "Hello, World!"
20
Fill in the Blanks
21
Fill in the Blanks
PYTHON STRINGS
By Klea h
Show answer
Auto Play
Slide 1 / 21
SLIDE
Similar Resources on Wayground
16 questions
Types of Speciation
Presentation
•
8th Grade
16 questions
Negative tú commands
Presentation
•
8th Grade
16 questions
8th Grade Review
Presentation
•
8th Grade
14 questions
Computer Science History
Presentation
•
8th Grade
15 questions
Logic Gates
Presentation
•
9th Grade
17 questions
Computer Software
Presentation
•
7th Grade
16 questions
Mars
Presentation
•
KG - 8th Grade
16 questions
Introduction to Plate Tectonics
Presentation
•
8th Grade
Popular Resources on Wayground
11 questions
Hallway & Bathroom Expectations
Quiz
•
6th - 8th Grade
10 questions
HCS SCI 03 Summer School Assessment 2
Quiz
•
3rd Grade
11 questions
Home Scope
Quiz
•
7th - 8th Grade
12 questions
2026 TAP Technology in the Classroom
Presentation
•
Professional Development
15 questions
HCS SCI 05 Summer School Assessment 2 Review
Quiz
•
5th Grade
15 questions
HCS SCI 04 Summer School Review 2
Quiz
•
4th Grade
59 questions
Geometry Unit 3 Review
Quiz
•
9th - 12th Grade
14 questions
FAST ELA READING SMAPLE TEST MATERIALS
Passage
•
3rd Grade