
Python Strings Quiz
Authored by Sujay Sangana
Mathematics
University
Used 1+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What does the negative index in Python string slicing represent?
A. Characters from the start of the string
B. Characters from the end of the string
C. Characters in uppercase
D. Characters in lowercase
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following code snippet: `print(s[-4])` if `s = "AIMLWhales"`?
A. l
B. a
C. W
D. h
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which Python construct is used to iterate through each character in a string?
while loop
if statement
for loop
switch statement
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What happens during each iteration of the for loop when iterating through a string?
The loop skips every second character.
The loop pulls characters in order and prints the next character.
The loop reverses the string.
The loop stops after the first character.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
In the example provided, how is the first character of the string changed?
By directly modifying the string.
By creating a new string using concatenation.
By using a loop to replace the character.
By using a built-in function to replace the character.
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Given the string `s = "AIMLWhales"`, what will `print("Whales" in s)` output?
True
False
Error
None
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What does the `clear()` method do to a list in Python?
Removes all items from the list.
Adds an element at the end of the list.
Adds multiple elements to the end of the list.
Adds an element at a specific position.
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Microsoft
or continue with
%20(1).png)
Apple
Others
Already have an account?