Skip to the main content
PeabodyMake a free story

🤖 Code & Robots, level 3

What the trails say and what they ask. Print it for the class, or put the same questions on the board with a live quiz.

Code & Robots, level 3

🔁 Loops

How do you tell a robot to do something again and again?

  • How do you tell a robot to do something again and again? You could tell it "go right" three times in a row. But coders have a shortcut. It is called a loop. A loop tells the robot to repeat the same steps a certain number of times.
  • Instead of writing right, right, right, you can write one block that says: repeat three times, go right. It does the same thing with fewer blocks. Loops make programs shorter and easier to read, and they make mistakes easier to spot and fix.
  • A loop can hold more than one step. Repeat two times: go up, then go right. That makes the robot climb as if it were walking up stairs. Before you run a loop, count the steps you need, and then pick the right number.

Try it at home: Make a dance loop: repeat 3 times, clap, stomp, spin. Take turns writing a loop for each other to follow.

Questions and answers

Loops

  1. 🔁 A loop tells a robot to… repeat steps
  2. ➡️ Right, right, right, right is the same as… Repeat 4 times: →
  3. Why do coders use loops? To make programs shorter
  4. 🦘 Repeat 3 times: jump. How many jumps? 3
  5. 👏 Repeat 2 times: clap, stomp. How many claps? 2 (Each time round there is one clap, and it goes round twice.)
  6. 🔢 Before you run a loop, what should you count? The steps you need