
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
10 questions
IT-Зарядка
Quiz
•
5th Grade - University
10 questions
Cuestionario Steve Jobs
Quiz
•
12th Grade - University
15 questions
Chapter 8 - Memory Management Strategies
Quiz
•
University
10 questions
Hands-on Modul 3
Quiz
•
University
10 questions
CS100||MsWord
Quiz
•
University
11 questions
Types of Mass Media
Quiz
•
10th Grade - Professi...
15 questions
Introducción Redes Tele1 IB
Quiz
•
10th Grade - University
10 questions
Software dan Hardware
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
54 questions
Analyzing Line Graphs & Tables
Quiz
•
4th 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
