Bird
0
0

Which situation best shows why a while loop is needed instead of a for loop?

easy📝 Conceptual Q2 of 15
Python - While Loop
Which situation best shows why a while loop is needed instead of a for loop?
AWhen you want to repeat until a condition changes
BWhen you know exactly how many times to repeat
CWhen you want to loop through a list
DWhen you want to define a variable
Step-by-Step Solution
Solution:
  1. Step 1: Compare for and while loops

    for loops repeat a set number of times; while loops repeat until a condition changes.
  2. Step 2: Identify the situation needing while

    If the number of repeats is unknown and depends on a condition, while is needed.
  3. Final Answer:

    When you want to repeat until a condition changes -> Option A
  4. Quick Check:

    Why while loop is needed = Repeat until condition changes [OK]
Quick Trick: Use while when repeat count is unknown [OK]
Common Mistakes:
MISTAKES
  • Using for loop when condition is unknown
  • Assuming while loops only work with numbers
  • Confusing loop types

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes