Recall & Review
beginner
What does the
while True loop do in Python?It creates an infinite loop that keeps running until it is stopped by a
break statement or an external interruption.Click to reveal answer
beginner
How do you stop a
while True loop inside the loop?You use the
break statement to exit the loop when a certain condition is met.Click to reveal answer
intermediate
Why might you use a
while True loop instead of a while loop with a condition?Using
while True lets you write the exit condition inside the loop body, which can make the code easier to read and handle complex exit conditions.Click to reveal answer
beginner
What is a common real-life example where
while True is useful?When waiting for user input repeatedly until they enter a valid response, like asking for a password until it is correct.
Click to reveal answer
beginner
What happens if you forget to include a
break in a while True loop?The program will run forever, causing an infinite loop that can freeze or crash your program.
Click to reveal answer
What keyword is used to exit a
while True loop?✗ Incorrect
The
break statement immediately stops the loop and exits it.What will happen if a
while True loop has no break?✗ Incorrect
Without a
break, the while True loop never stops on its own.Which of these is a good use case for
while True?✗ Incorrect
while True is great for loops that run until a condition inside the loop is met, like user input validation.What does the
continue statement do inside a while True loop?✗ Incorrect
continue skips the rest of the current loop and starts the next iteration.Which of these is NOT true about
while True loops?✗ Incorrect
while True loops do not stop automatically after any number of iterations.Explain how a
while True loop works and how to safely stop it.Think about what keeps the loop running and what stops it.
You got /3 concepts.
Describe a real-life scenario where using a
while True loop is helpful.Imagine asking someone for input until they give a correct answer.
You got /4 concepts.