Font size
Worksheetsgrade 7&8 week 15
Total questions: 50
Worksheet time: 38mins
What is selection in programming?
Repeating a process
Choosing actions based on a condition
Declaring variables
Ending a loop
What is iteration in programming?
A. A one-time decision
B. Repeating a set of instructions
C. A variable declaration
D. Data storage
Which keyword is used for selection in Python?
for
while
if
repeat
Which of the following uses iteration?
if x > 5:
while x < 10:
print(x)
input(x)
Why do we combine selection and iteration?
To run code once
To test conditions multiple times inside a loop
What is the output? for i in range(3): if i == 1: print("Yes")
Yes Yes Yes
Yes
1 2 3
None
Which of these loops runs exactly 5 times?
for i in range(6):
for i in range(5):
while i < 6:
for i in range(1,6,2):
What happens when a loop has a false condition?
It restarts
It stops
It prints False
It skips the code
for i in range(4): if i % 2 == 0: print(i)
1 3
0 2
0 1 2 3
None
Which statement ends a loop early?
continue
exit
break
return
Which statement skips the current iteration?
skip
continue
pass
break
What will this print? for i in range(5): if i == 2: continue print(i)
A. 0 1 2 3 4
B. 0 1 3 4
C. 2 3 4
D. 1 2 3
What is the output? for x in range(3): if x != 1: print(x)
A. 1
B. 0 1 2
C. 0 2
D. 2
Which loop repeats while a condition remains True?
for
repeat
while
until
How many times will this loop run?
5
10
2
Infinite
What does if-else do inside a loop?
It allows different actions to be taken based on conditions during each iteration.
It ends the loop immediately when a condition is met.
It skips the current iteration and moves to the next one.
It prevents the loop from running at all.
What is printed? count = 0 for i in range(4): if i % 2 == 0: count += 1 print(count)
4
2
3
1
If you forget to increment in a while loop, what happens?
Error
Infinite loop
Skipped condition
Program closes
What keyword is used to define an infinite loop intentionally?
for i in range(∞)
while True:
loop forever:
repeat()
In a for loop, what does range(3) mean?
0 to 3
0, 1, 2
1 to 3
1, 2, 3
Which line demonstrates combining selection and iteration?
if score > 50:
while True:
for x in range(5): if x > 2: print(x)
print("Done")
Which of these prints only even numbers from 1–10?
A. if i % 2 == 1:
B. for i in range(10): if i % 2 == 0: print(i)
C. for i in range(10): print(i)
D. while i == 10:
What is the output? for i in range(5): if i == 3: break print(i)
A. 0 1 2 3
B. 0 1 2
C. 3
D. None
Which of these is NOT an example of iteration?
for
while
if
repeat
What happens when you put if inside a loop?
The loop runs once
The decision runs each time the loop iterates
The loop stops immediately
Syntax error
What is the result of this code? for i in range(3): if i == 1: continue print(i)
0 2
0 1
1 2
2
When does the else in a loop execute?
Always
Only if the loop finishes without a break
When a continue is used
What is the output? for i in range(3): if i == 2: print('End') print('Done')
End Done
Done
End
Error
Which will print “Odd”?
1
0 2
0 1 2
None
What is the output? x = 1 while x < 4: if x == 2: print('Middle') x += 1
Middle
None
Error
1 2 3
What does continue do inside a loop?
Stops the program
Skips to the next iteration
Ends the loop
Restarts the loop
What is the function of break in a nested loop?
Ends the entire program
Stops only the innermost loop
Restarts the outer loop
Skips an iteration
What is printed? for i in range(2): for j in range(2): if i == j: print("Equal")
4 times
2 times
1 time
None
Which code snippet prints all multiples of 3 from 1 to 9?
Which code counts even numbers in a list?
If the loop condition is always True, and no break is used:
Loop runs once
Loop runs infinitely
Loop doesn’t start
Error
What will happen? for i in range(3): if i > 5: print(i)
Prints 0 1 2
No output
Error
What does nested iteration mean?
A. A loop inside a loop
B. Two if statements
C. Multiple variables
D. None
Which is true about selection statements?
They cannot be nested
They can exist inside loops
They must end with break
They repeat indefinitely
What’s the output? for i in range(4): if i < 2: print("Low") else: print("High")
What does this code print?
What is the output? for i in range(2): for j in range(3): print(i, j)
What is selection sometimes called?
Decision making
Looping
Storage
Repetition
What is the output of the following code?
break
print(i)
i += 1
(a)
Which example uses both for loop and if-else?
(a)
What is printed?
for i in range(4):
if i == 2:
print("Two")
(a)
What is output if condition is always false in a loop?
No iteration happens
One iteration happens
Infinite loop
Error
When combining selection and iteration, where can if appear?
Only outside loop
Inside or outside loop
Only once
Not allowed
How many times is this executed? for i in range(2): for j in range(3): print("Run")
6 times
2 times
3 times
5 times
Why is combining selection and iteration powerful?
Allows complex, condition-based repetition
Shortens code
Prevents syntax errors
Stops loops
