Lesson 10 of 12

While Loops ⏳

🎯 Grades 6–8 ⏱ ~25 minutes 💚 Intermediate

What You'll Learn

  • Use while loops to repeat code while a condition is True
  • Avoid infinite loops by always updating the loop variable
  • Know when to choose while vs for
Quick Check

1. When does a while loop stop running?

AAfter exactly 10 iterations
BWhen its condition becomes False
CWhen you press the stop button

2. Why must you update the loop variable inside the loop?

ATo make the loop run faster
BSo the condition eventually becomes False and the loop ends
CTo print the variable correctly

3. Which keyword exits a loop immediately?

Acontinue
Bbreak
Cstop

4. Which loop is best when you don't know the number of iterations in advance?

Afor loop
Bwhile loop
Crepeat loop