Mansori

Loops Make a Dance

About this lesson, for parents and teachers

Our dancer loves to move, but writing every single step takes forever. What if one block could say do it again? Let's make a loop!

Ages 6–8 · about 6 minutes · builds on Algorithms Are Recipes · leads to Find the Bug!, When Clicked: Events

Try this

  1. Look at the dance at the top. Tap a move to put it in the repeat block.
  2. Tap the number on the repeat block to change how many times it repeats.
  3. Press Play and watch the dancer. A green dot means that move was right.
  4. Stuck? Press Show me to see one way to build it.

How it works

A program is a list of steps for a computer to follow. Sometimes the same steps happen again and again, like clap, clap, clap, clap. Writing the same block four times works, but it is slow and easy to get wrong. A loop is a block that says: do these steps again, this many times.

The repeat block has a number and a space inside it. The moves inside are called the body of the loop. If the body is step left, step right and the number is 3, the computer runs left, right, left, right, left, right. Two moves inside one loop made six moves on the dance floor.

Before the dancer moves, the computer reads the repeat block and makes the full list of steps. Then it does them one by one. Watch the ring around the number fill up. It shows which time through the loop the dancer is on. Each time the ring goes all the way round, the loop starts its body again from the first move. When the count runs out, the loop is finished and the program moves on.

If the number is too small, the dance ends early. If it is too big, the dancer keeps going after the music stops. Finding the right number is a big part of using loops well. Programmers use loops everywhere, because computers are very good at doing the same thing many times without getting tired.

Where engineers use this

Games use loops to draw the screen about 60 times every second, and a music app uses a loop when you press repeat on a song.

Words to know

Loop
A block that repeats the steps inside it.
Repeat
To do something again. A repeat block has a number that says how many times.
Body
The steps inside a loop. They run once each time around.

Talk about it

Goal: Use a repeat block so a dancer repeats moves without writing them again and again.

  • What do you do again and again every day? Could you write it as a loop?
  • If a song goes clap, stomp, clap, stomp, clap, stomp, what is inside the loop and how many times does it repeat?
  • What would happen if a loop never stopped?

Without a screen: Write three dance moves on sticky notes (clap, jump, spin). Draw a big box on paper with a number circle on top. Your child puts notes inside the box and picks a number, then you perform the loop together. Swap roles so they read the program while you dance.

Curriculum links: CSTA K-12 1A-AP-10 (programs with sequences and simple loops); CSTA K-12 1A-AP-08 (model daily processes with algorithms)

Questions

What is a loop in coding for kids?
A loop is an instruction that tells the computer to repeat some steps. Instead of writing clap four times, you write repeat 4 times with one clap inside.

What is a repeat block?
In block-based coding tools like Scratch and ScratchJr, a repeat block is a loop with a number on it. The blocks you place inside it run that many times, one after another.

Why do programmers use loops?
Loops make programs shorter, easier to read and easier to fix. If you want to change the dance, you change one block inside the loop instead of every copy.