NEW
Font size
WorksheetsGrade 7 – Python For Loops Questions
Total questions: 40
Worksheet time: 20mins
What does a for loop do in Python?
Repeats a block of code
Stops the program
Defines a variable
Creates a new function
Which keyword is used to start a for loop?
for
loop
repeat
while
What does range(5) generate?
Numbers 0 to 4
Numbers 1 to 5
Numbers 0 to 5
Only number 5
How many times does this loop run? for i in range(3):
3 times
2 times
4 times
1 time
What is i in for i in range(5)?
Loop variable
Function
Condition
String
What will range(2, 6) produce?
2,3,4,5
2,3,4,5,6
1,2,3,4,5
3,4,5,6
What type does range() return?
A sequence
A string
A float
A dictionary
Which loop is best for repeating code a fixed number of times?
for loop
while loop
if statement
function
What will this print? for i in range(3): print(i)
0 1 2
1 2 3
3 2 1
Nothing
Where should indentation be used?
Inside loop body
Before for
After print
No need
What does range(1,10,2) generate?
1 3 5 7 9
1 2 3 4
2 4 6 8
1 5 9 13
What does break do in a loop?
Stops the loop
Repeats the loop
Skips iteration
Restarts program
What does continue do?
Skips to next iteration
Stops loop
Repeats last step
Exits program
Can a for loop iterate over a list?
Yes
No
Only numbers
Only strings
What will len([1,2,3]) return?
3
2
1
Error
Which is correct?
for x in [1,2,3]:
loop x in list:
repeat x:
for each x:
What will print? for c in 'abc': print(c)
a b c
abc
a
Nothing
What does this loop do? for i in range(10): pass
Does nothing
Prints numbers
Stops
Repeats forever
Which loop is this? for a in range(4):
Counting loop
While loop
Conditional
Function loop
range(0) produces:
An empty sequence
0
1
Error
A for loop can repeat code multiple times. (True / False)
True
False
range(5) gives numbers 1 to 5. (True / False)
True
False
Indentation is required inside a for loop. (True / False)
True
False
A for loop can iterate through a string. (True / False)
True
False
range(3) produces 0,1,2. (True / False)
True
False
break stops the entire loop. (True / False)
True
False
continue skips the current iteration. (True / False)
True
False
You must use range() in every for loop. (True / False)
True
False
A for loop can iterate over a list. (True / False)
True
False
Python is case-sensitive. (True / False)
True
False
range(2,8) includes number 8. (True / False)
True
False
for i in range(1) runs once. (True / False)
True
False
A loop variable changes every iteration. (True / False)
True
False
You can nest one loop inside another. (True / False)
True
False
Strings are sequences in Python. (True / False)
True
False
range(10,0,-1) counts down. (True / False)
True
False
A loop cannot run zero times. (True / False)
True
False
for loops always need a list. (True / False)
True
False
Loops help reduce repeated code. (True / False)
True
False
pass means 'do nothing'. (True / False)
True
False
