Lesson 3: Loops

⏱ ~15 min Lesson 3 of 8 💚 Free

What if you want a character to hop 10 times? You could write 'hop' 10 times... or you could use a loop! A loop repeats instructions over and over — it's one of the most powerful ideas in all of coding.

Key Concepts

What Is a Loop?

A loop tells a computer to do something again and again. 'Repeat 5 times: hop' is a loop. Instead of writing 'hop' five times, you just say to repeat it.

Why Loops Save Time

Imagine drawing 100 circles without a loop vs. with a loop. Without: 100 lines of code. With a loop: just 2-3 lines! Loops make programs shorter and easier to write.

Loop Count

You can control how many times a loop runs. 'Repeat 3 times' runs 3 times. 'Repeat forever' runs until you stop it. Knowing when to stop is important!

🆕 Activity: Loop Artist

Set how many times to repeat and which drawing steps to include. Press Draw to see your loop create a pattern!

✅ Check Your Understanding

1. What does a loop do?

2. Why are loops useful?

3. A 'repeat 4 times' loop runs the code: