
List and string methods
Presentation
•
Science, Computers, Education
•
11th - 12th Grade
•
Medium
Akniyet Sarsenbek
Used 5+ times
FREE Resource
17 Slides • 15 Questions
1
List and string methods
By Akniyet Sarsenbek
2
Learning objectives
11.2.2.3apply functions and string processing methods;
11.2.3.3apply functions and methods of processing lists;
11.4.3.2 solve applied problems of various subject areas;
Some text here about the topic of discussion
3
Multiple Choice
String revision QUIZ
Use the len method to print the length of the string.
x = "Hello World"
len.x
print(len(x))
x.len()
print(len)
4
Multiple Choice
Get the first character of the string txt.
txt = "Hello World"
x =
txt(1)
txt(0)
txt[0]
txt[1]
5
Multiple Choice
Get the characters from index 2 to index 4 (llo).
txt = "Hello World"
x =
txt[2 : 5]
txt[2 : 4]
txt[2 : 6]
txt[1 : 5]
6
Multiple Choice
What does the following Python Program print out?
Hello
there
0
Hellothere
Hello
7
Multiple Choice
What does the following Python program print out?
x2
int402
402
42
8
Multiple Choice
How would you use the index operator [] to print out the letter q from the following string?
x = 'From marquard@uct.ac.za'
print(x[q])
print(x[8])
print(x[9])
print(x[7])
9
Multiple Choice
How would you use string slicing [:] to print out 'uct' from the following string?
x = 'From marquard@uct.ac.za'
print(x[14:3])
print(x[14:17])
print(x[15:18])
print(x[14/17])
10
Multiple Choice
What does the following Python code print out?
banana7
42
-1
banana banana banana banana banana banana banana
11
String methods
count() method
Return the number of times the value "apple" appears in the string:
txt = "I love apples, apple are my favorite fruit"
x = txt.count("apple")
print(x)
Some text here about the topic of discussion
12
find() method
The find() method finds the first occurrence of the specified value.
The find() method returns -1 if the value is not found.
txt = "Hello, welcome to my world."
x = txt.find("welcome")
print(x)
Subject | Subject
Some text here about the topic of discussion
13
index() method
The index() method finds the first occurrence of the specified value.
The index() method raises an exception if the value is not found.
The index() method is almost the same as the find() method, the only difference is that the find() method returns -1 if the value is not found.
txt = "Hello, welcome to my world."
x = txt.index("welcome")
print(x)
Subject | Subject
Some text here about the topic of discussion
14
replace() method
The replace() method replaces a specified phrase with another specified phrase.
txt = "I like bananas"
x = txt.replace("bananas", "apples")
print(x)
Subject | Subject
Some text here about the topic of discussion
15
split() method
The split() method splits a string into a list.
You can specify the separator, default separator is any whitespace.
txt = "welcome to the jungle"
x = txt.split()
print(x)
Subject | Subject
Some text here about the topic of discussion
16
upper() method
The upper() method returns a string where all characters are in upper case.
Symbols and Numbers are ignored.
txt = "Hello my friends"
x = txt.upper()
print(x)
Subject | Subject
Some text here about the topic of discussion
17
lower() method
The lower() method returns a string where all characters are lower case.
Symbols and Numbers are ignored.
txt = "Hello my FRIENDS"
x = txt.lower()
print(x)
Subject | Subject
Some text here about the topic of discussion
18
format() method
The format() method formats the specified value(s) and insert them inside the string's placeholder. The placeholder is defined using curly brackets: {}.The format() method returns the formatted string.
txt = "For only {price} dollars!"
print(txt.format(price = 49))
Subject | Subject
Some text here about the topic of discussion
19
strip() method
The strip() method removes any leading (spaces at the beginning) and trailing (spaces at the end) characters (space is the default leading character to remove)
txt = " banana "
x = txt.strip()
print("of all fruits", x, "is my favorite")
Subject | Subject
Some text here about the topic of discussion
20
There are a lot of other string methods. Other methods are listed in the link below.
Some text here about the topic of discussion
21
Fill in the Blanks
Type answer...
22
Fill in the Blanks
Type answer...
23
Fill in the Blanks
Type answer...
24
Fill in the Blanks
Type answer...
25
Fill in the Blanks
Type answer...
26
Multiple Choice
Which of the following is not a valid string method in Python?
upper()
lower()
middle()
strip()
27
Solve string problems
Some text here about the topic of discussion
28
29
30

Python | Check if a given string is binary string or not - GeeksforGeeks
You can open this webpage in a new tab.
31
Open Ended
Ask any questions.
32
The lesson is over.
List and string methods
By Akniyet Sarsenbek
Show answer
Auto Play
Slide 1 / 32
SLIDE
Similar Resources on Wayground
23 questions
Ch 7.3/4 Gustation and Olfactory Perception
Presentation
•
11th - 12th Grade
25 questions
Water Pollution presentation
Presentation
•
11th - 12th Grade
25 questions
Periodic Trends
Presentation
•
10th - 12th Grade
26 questions
Newton's Second Law
Presentation
•
11th Grade
24 questions
Taxonomy and Classification
Presentation
•
11th Grade
24 questions
history of computers
Presentation
•
10th - 12th Grade
27 questions
Understanding Populations
Presentation
•
11th - 12th Grade
25 questions
The internet
Presentation
•
12th Grade
Popular Resources on Wayground
15 questions
Grade 3 Simulation Assessment 1
Quiz
•
3rd Grade
22 questions
HCS Grade 4 Simulation Assessment_1 2526sy
Quiz
•
4th Grade
16 questions
Grade 3 Simulation Assessment 2
Quiz
•
3rd Grade
19 questions
HCS Grade 5 Simulation Assessment_1 2526sy
Quiz
•
5th Grade
17 questions
HCS Grade 4 Simulation Assessment_2 2526sy
Quiz
•
4th Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
24 questions
HCS Grade 5 Simulation Assessment_2 2526sy
Quiz
•
5th Grade
20 questions
Math Review
Quiz
•
3rd Grade
Discover more resources for Science
20 questions
Earth Day Trivia
Quiz
•
9th - 12th Grade
100 questions
Biology EOC Review
Quiz
•
9th - 12th Grade
20 questions
Earth Day
Quiz
•
3rd - 12th Grade
20 questions
Cladograms and Phylogenetic Trees
Quiz
•
9th - 12th Grade
31 questions
STAAR Strand 1 TEKS(11,12)
Quiz
•
9th - 12th Grade
16 questions
Taxonomy and Classification
Quiz
•
6th - 12th Grade
50 questions
Biology EOC Review
Quiz
•
9th - 12th Grade
37 questions
Hydrosphere CSA wayground review
Quiz
•
9th - 12th Grade