Full lesson Loops 3–7 min

Loops with a Stop Sign!

How many puffs does a party balloon need?

Real Python code

This is the code from the video. Read it out loud like a recipe, one line at a time!

balloon.py
air = 0

while air < 50:
    air = air + 10
    print("Puff!")

print("Party time!")

Quiz time!

How many puffs does this code print?

quiz.py
air = 0
while air < 30:
    air = air + 10
    print("Puff!")

Stop sign loops are everywhere

Games

Keep playing until the game is over

Loading

Keep loading until everything is ready

The bus stop

Keep waiting until the bus comes

AI training

Repeat practice rounds until the mistakes are small enough

Which loop do I need?

repeat 10

  • You know the number
  • Like: jump ten times
  • Counts, then stops
VS

repeat until

  • You know the stop sign
  • Like: puff until it's big
  • Checks before every round
  • Something inside must change

Know the number? repeat. Know the stop sign? repeat until!

Try it yourself!

In Scratch, make a sprite walk with repeat until touching edge, then say Made it!

Bit is working on the next one: Random numbers

Liked this quest?

Subscribe to see the next one first! Ask a grown-up before subscribing.

Keep exploring