Full lesson Loops 3–7 min

Loops: Repeat Magic!

Can you make a robot jump 100 times with just 3 blocks?

Real Python code

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

jump.py
for count in range(5):
    print("Jump!", count + 1)

print("Yay! All done!")

Quiz time!

How many times will this say Hi!?

quiz.py
for i in range(3):
    print("Hi!")

Where loops hide

Games

Move every character, many times a second

Drawing

Repeat 4 times: draw a line, turn. A square!

AI

Practise on examples again and again

Chat apps

Show every message, one by one

What we learned

The long way

  • 100 jump blocks
  • Easy to make mistakes
  • Hard to change
VS

With a loop

  • 1 repeat block
  • Short and tidy
  • Change just one number

Loops = repeat magic!

Try it yourself!

Open Scratch and make a sprite dance with a repeat block.

Bit is working on the next one: Variables: boxes that remember things

Liked this quest?

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

Keep exploring