
Strings Quiz
Authored by Halil Ozer
Computers
9th - 12th Grade
Used 177+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
About
This quiz focuses on Python string manipulation and covers essential programming concepts appropriate for grades 9-12. The questions systematically assess students' understanding of string slicing using bracket notation and indices, including positive and negative indexing to access specific characters or substrings. Students must demonstrate mastery of string immutability principles, understanding why certain operations like direct character assignment are illegal in Python. The quiz also evaluates comprehension of string iteration using for loops, the "in" operator for substring detection, and built-in string methods such as find(), upper(), and lower(). Advanced concepts include function writing with string manipulation logic, proper variable assignment and concatenation techniques, and the ability to trace through code execution to predict outputs. Students need solid foundational knowledge of zero-based indexing, loop control structures, conditional statements, and function definition syntax to successfully complete these problems. Created by Halil Ozer, a Computers teacher in the US who teaches grades 9-12. This comprehensive assessment serves multiple instructional purposes throughout a programming unit on strings. Use it as a diagnostic tool at the beginning of string instruction to gauge prior knowledge, or deploy it as formative assessment during lessons to identify specific areas where students struggle with indexing or string methods. The quiz works effectively as guided practice during computer lab sessions, allowing students to test their understanding immediately after learning new concepts. Teachers can assign it as homework following string manipulation lessons, providing students opportunity to reinforce learning outside the classroom. The varied question types make it valuable for review sessions before unit tests or standardized assessments. This quiz aligns with Computer Science standards that emphasize fundamental programming constructs, data types, and problem-solving through code analysis, supporting curriculum goals for introductory programming courses at the high school level.
Content View
Student View
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Which of the following expressions will result in “brown”?
Let sentence = "The brown lazy dog"
print(sentence[4:8])
print(sentence[4:9])
print(sentence[3:8])
print(sentence[3:9]) print(sentence[3:9])
2.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Which of the following expressions will print “dog”?
Let sentence = "lazy dog"
print(sentence[6:])
print(sentence[:])
print(sentence[:5])
print(sentence[5:])
3.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Which of the following expressions will print “L”?
Let word = "PINEAPPLE"
print(word[-4:])
print(word[-1])
print(word[-2])
print(word[-3])
4.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Which of the following string operation is illegal? Assume that word = "music".
word[0] = "M"
word = word[2] + word[-1]
word = "musical"
word = word + "al"
5.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Which of the following expressions will get the last character in a string? Assume that word is a string variable.
I. word[0]
II. word[-1]
III. word[len(word)]
IV. word[len(word)-1]
I, II, III
II, IV
II, III, IV
I, IV
6.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What is the output of the following program?
sentence = "the dog"
for letter in sentence:
print(letter + letter)
t
h
e
d
o
g
t
h
e
d
o
g
t
h
e
d
o
g
tt
hh
ee
dd
oo
gg
The program will cause an error
7.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Which of the following if statements checks if the string variable sentence contains the word “the”?
if "t" or "h" or "e" in sentence:
print("Contains 'the'")
if "the" in sentence:
print("Contains 'the'")
if "the" == sentence:
print("Contains 'the'")
if sentence in "the":
print("Contains 'the'")
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 Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?