
Practice: Iteration
Authored by Wayground CTE
Information technology (IT)
9th Grade
Blooms Level: Apply covered

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
17 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Which loop should be used when iterating through every character in a string?
A for loop using input()
A for loop over the string
A while loop with a counter
A nested while loop structure
Answer explanation
A for loop directly iterates over each character in a string without manual indexing. A while loop works but requires extra counter management that is unnecessary.
Tags
Blooms Level: Apply
2.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
How many times does the inner statement run: for i in range(3): for j in range(4): print(i,j)?
16 times
12 times
7 times
9 times
Answer explanation
Nested loops multiply iterations: 3 outer times 4 inner equals 12. Adding the ranges instead of multiplying them is a common mix-up that produces 7.
Tags
Blooms Level: Apply
3.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
In a number-guessing game using while True, which statement ends the loop after a correct guess?
Continue
Pass
Break
Return
Answer explanation
break exits the infinite loop immediately when the correct guess is made. continue only skips to the next iteration, leaving the loop running.
Tags
Blooms Level: Apply
4.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Which loop runs its body at least once even if the condition is initially false?
Python for loop only
Python while loop only
Both for and while loops
None of Python's built-in loops
Answer explanation
Python has no do-while construct; both while and for loops check the condition before the first iteration, so neither guarantees one execution.
Tags
Blooms Level: Understand
5.
MULTIPLE SELECT QUESTION
2 mins • 2 pts
Which TWO statements about the continue statement are true? (Select all that apply)
It exits the loop entirely
It restarts the loop from the first iteration
It skips the remaining code in the current iteration
It moves to the next iteration of the loop
It raises a StopIteration exception
Answer explanation
continue jumps past the rest of the current iteration and proceeds to the next one. It does not exit or restart the loop.
Tags
Blooms Level: Understand
6.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Which while header keeps prompting until input is between 1 and 10 inclusive?
While x < 1 and x > 10:
While 1 < x < 10:
While not x in range(10):
While x < 1 or x > 10:
Answer explanation
The loop must continue while the value is outside the valid range, meaning below 1 OR above 10. Using and would require both conditions simultaneously, which is impossible.
Tags
Blooms Level: Apply
7.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What is the role of pass inside an empty else clause of a for loop?
Exits the loop early
Skips the current iteration
Repeats the previous iteration
Acts as a no-op placeholder
Answer explanation
pass satisfies Python's requirement for a non-empty block without performing any action. It does not affect loop control in any way.
Tags
Blooms Level: Understand
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?