
for loop quiz
Quiz
•
Computers
•
University
•
Practice Problem
•
Medium
thanga_palani_ thanga_palani_
Used 1+ times
FREE Resource
Enhance your content in a minute
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 Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
15 questions
CODE ZENITH
Quiz
•
University
10 questions
UAS SISTEM PENDUKUNG KEPUTUSAN SUSULAN
Quiz
•
University
10 questions
Microcontroller
Quiz
•
11th Grade - University
14 questions
Input, output and storage de
Quiz
•
8th Grade - Professio...
15 questions
IT 209
Quiz
•
University
15 questions
Assessment 08
Quiz
•
University
10 questions
1ª Recuperação - 3° Trim. - Pensamento Computacional - 9º ano
Quiz
•
9th Grade - University
7 questions
ESBrotherX_Medical AI_Lecture
Quiz
•
University
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade
20 questions
Figurative Language Review
Quiz
•
6th Grade
