
for loop quiz
Authored by thanga_palani_ thanga_palani_
Computers
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 a for loop do?
Repeats a block of code
Skips a line
Runs code once
Stops the program
Answer explanation
For loop repeats code for each item or number
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output?
for i in range(3):
print(i)
1 2 3
0 1 2
0 1 2 3
1 2
Answer explanation
range(3) goes from 0 to 2
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
for i in range(1, 4) will print:
1 2 3
0 1 2
1 2 3 4
2 3 4
Answer explanation
Starts at 1, stops before 4
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which is the correct for loop syntax?
for i in range(5):
for i = 5
for i -> 5
for in range(5)
Answer explanation
Python uses for variable in range():
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What does range(2, 10, 2) do?
2 to 10
2, 4, 6, 8
2, 4, 6, 8, 10
1, 2, 3, 4
Answer explanation
Step of 2 means it skips numbers
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output?
for ch in "hi":
print(ch)
hi
h i
i h
Error
Answer explanation
Loops over each character
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What data type works with a for loop?
Only numbers
Strings, lists, ranges
Only strings
Only booleans
Answer explanation
Can loop over anything that’s a sequence
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?