
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
Return the string without any whitespace at the beginning or the end.
Type answer...
22
Fill in the Blanks
Convert the value of txt to upper case.
Type answer...
23
Fill in the Blanks
Convert the value of txt to lower case.
Type answer...
24
Fill in the Blanks
Replace the character H with a J. Write the needed words with spaces.
Type answer...
25
Fill in the Blanks
Insert the correct syntax to add a placeholder for the age parameter.
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
27 questions
What is Biodiversity?
Presentation
•
11th - 12th Grade
21 questions
ohms law
Presentation
•
11th - 12th Grade
22 questions
Ion Formation and Ionic Bonding
Presentation
•
10th - 12th Grade
27 questions
APES Math Review
Presentation
•
11th - 12th Grade
24 questions
Disease & Disorders of the Integumentary System
Presentation
•
12th Grade
27 questions
Heart and EKG Review
Presentation
•
11th - 12th Grade
23 questions
Ecosystems and Biomes
Presentation
•
11th - 12th Grade
24 questions
Computer Networks
Presentation
•
11th Grade
Popular Resources on Wayground
6 questions
PRIDE Always and Everywhere
Presentation
•
12th Grade
20 questions
Lab Safety Quiz
Quiz
•
6th Grade
26 questions
KOR Review Kahoot Questions
Quiz
•
8th Grade
21 questions
Continents and Oceans
Quiz
•
6th Grade
12 questions
Unit Zero lesson 2 cafeteria
Presentation
•
9th - 12th Grade
20 questions
Parts of Speech
Quiz
•
5th Grade
10 questions
Riddles Riddles fun Riddles
Quiz
•
6th - 12th Grade
16 questions
Subject & Predicate
Quiz
•
5th Grade
Discover more resources for Science
16 questions
Identify Key Characteristics of Living Organisms
Quiz
•
9th - 12th Grade
26 questions
Introduction to Anatomy and Physiology
Quiz
•
11th Grade
19 questions
Explore Macromolecules in Living Organisms
Quiz
•
9th - 12th Grade
20 questions
Reading Graphs in Science
Quiz
•
9th - 12th Grade
30 questions
Identifying Artificially Generated Images
Quiz
•
9th - 12th Grade
5 questions
Ch 14 - Ecology
Quiz
•
9th - 12th Grade
23 questions
Specific heat capacity (conceptual)
Quiz
•
9th - 12th Grade
16 questions
Significant Figures and Scientific Notation Mastery Quiz
Quiz
•
11th Grade