Unit 3
Repeating steps
Spot the part that keeps happening and write it once, as "repeat 3 times".
Read
Do it again, and again
Ishaan is teaching a robot to walk to the end of a long path. He writes:
Forward, Forward, Forward, Forward, Forward, Forward, Forward, Forward.
His hand is tired already! And what if the path were 100 squares long?
There is a better way. Ishaan can say the same thing in a few words: Repeat 8 times: Forward.
Repeat saves writing
When a step (or a few steps) happens again and again, you do not have to write it again and again. You write it once and say how many times to repeat it.
The steps inside the box are the part that gets repeated. The number says how many times.
Written out With repeat Forward, Forward, Forward Repeat 3 times: Forward Clap, Clap, Clap, Clap, Clap Repeat 5 times: Clap Repeating more than one step
You can repeat a whole group of steps. Look at this dance:
Clap, Stomp, Clap, Stomp, Clap, Stomp, Jump
Do you see a part that keeps coming back? Clap, Stomp appears three times in a row. Then there is one Jump.
Example. Write the dance with repeat.
- Find the part that repeats: Clap, Stomp.
- Count how many times in a row: 3.
- Write it once: Repeat 3 times: [Clap, Stomp].
- Add the steps that are left: Jump.
Now it is two lines instead of seven steps.
The Jump is not inside the box. It happens once, after the repeating is finished.
A robot staircase
Here is a robot climbing a staircase to the star. One round is: Forward, Turn right, Forward, Turn left. The robot goes up one square and right one square. After three rounds, it is on the star.
Written out, that is 12 steps. With repeat, it is just: Repeat 3 times: [Forward, Turn right, Forward, Turn left].
Two things people get wrong
Count what is inside the box, then multiply. "Repeat 3 times: [Forward, Forward]" is 6 Forward steps, not 3. Each round has 2 steps, and there are 3 rounds.
Only repeat what really repeats. Forward, Forward, Turn right is not "Repeat 3 times: Forward". The Turn right happens once, so it stays outside.
Try it: Use Loop it. Build each route using a repeat box, and see how short you can make it.
Why does this matter?
Computers repeat things all the time, millions of times, without getting tired. A computer program says "repeat" so that the person writing it does not have to. Repeating is one of the big ideas in programming. Later it is called a loop.
For the grown-up helping
Start with the body: do a clap-and-stomp pattern together before writing anything. Then ask "What keeps coming back?" Let your child find the repeating part. The most common slip is putting the one-off step inside the repeat, or forgetting that the number multiplies everything in the box. Run it with your finger or your feet to check.
Lab
Loop it
Get the robot to the star using Repeat boxes. Put the steps you want to repeat inside a box, choose how many times, and press Run. Short routes win.
Your goals
- Use a Repeat box to reach the star in four missions, one of them a staircase.
- Notice how many fewer lines a Repeat box needs than writing every step out.
The interactive lab opens once you register. Register to do this.
Activity
Dance with repeat
Your child makes up a dance, writes it with a repeat, and does it. Then they find the repeat in your dance. About 15 minutes.
You'll need
- Paper and a pencil or crayon
- A clear space on the floor
Steps
- Show three moves, for example clap, stomp and jump. Do them in a row together, "Clap, stomp, clap, stomp, clap, stomp, jump".
- Ask "What keeps coming back?" Let your child point to the repeating part on paper (write the seven moves for them if they cannot yet).
- Your child writes it the short way, for example "Repeat 3 times - clap, stomp. Then jump." Do the dance from the short version only.
- Your child makes up a new dance of at least 8 moves that has a repeat in it, and writes it the short way.
- You do your child's dance from the short version, exactly as written. If it comes out wrong, find the step together and fix it.
- Swap. You write a dance with a repeat and your child does it. Ask them to say how many moves they did in all.
Safety
- Clear the floor of toys and furniture, and keep away from stairs and sharp corners.
- Keep jumps small and low. Dance in socks only on a non-slippery floor, or barefoot.
Keeping a log of the activity is for registered learners. Register to do this.
Quick check
Repeating steps check
Seven questions about repeat. The steps inside the square brackets are the part that gets repeated.
1.The robot faces up. Which program takes it to the star?
- Repeat 2 times: [Forward]
- Repeat 3 times: [Forward]
- Repeat 4 times: [Forward]
Choose one
2.Repeat 3 times: [Forward, Forward]. How many Forward steps does the robot do in all?
Answer with a number
3.A robot does these steps: Forward, Forward, Forward, Turn left. Which is the same thing written with repeat?
- Repeat 3 times: [Forward, Turn left]
- Repeat 3 times: [Forward]. Then Turn left.
- Repeat 4 times: [Forward]
Choose one
4.Which is the shortest way to write this dance?
- Repeat 3 times: [Clap, Stomp, Jump]
- Repeat 3 times: [Clap, Stomp]. Then Jump.
- Repeat 6 times: [Clap, Stomp]
Choose one
5.Match each list of steps to the way of writing it with repeat.
- Forward, Forward, Forward, Forward, Forward
- Forward, Turn right, Forward, Turn right
- Turn left, Turn left, Turn left
Match each to: Repeat 5 times: [Forward] · Repeat 3 times: [Turn left] · Repeat 2 times: [Forward, Turn right]
6.The robot faces up and follows: Repeat 2 times: [Forward, Turn right, Forward, Turn left]. Which square does it stop in?
- A
- B
- C
Choose one
7.Why do programmers use repeat?
- It makes the robot move faster.
- It saves writing the same steps again and again.
- It makes the robot do new things it cannot do otherwise.
Choose one
Answering and checking are for registered learners. Register to do this.
Quick check
New puzzles
Repeat in new places. Look for the part that keeps coming back.
1.Meera plays a drum pattern: tap, tap, boom, tap, tap, boom, tap, tap, boom. Which is the shortest way to write it?
- Repeat 9 times: [tap, tap, boom]
- Repeat 3 times: [tap, tap, boom]
- Repeat 3 times: [tap, boom]
Choose one
2.Look at the gardening steps. Written with repeat they are: Repeat ___ times: [Plant, Water]. What number goes in the blank?
Answer with a number
3.The robot faces up on a big empty grid. It does: Repeat 5 times: [Forward]. Then Turn right. Then Repeat 2 times: [Forward]. How many squares does it move in all?
Answer with a number
4.Which list has a part that repeats?
- Forward, Turn left, Forward, Turn right, Forward
- Turn right, Forward, Turn right, Forward, Turn right, Forward
- Forward, Turn right, Turn left, Forward, Turn right
Choose one
5.A robot faces up on a big empty grid and does: Repeat 3 times: [Forward, Turn right]. Where does it end up?
- Three squares in a straight line from where it started
- One square to the right of where it started, after going round three sides of a square
- Back exactly where it started, facing up
Choose one
Answering and checking are for registered learners. Register to do this.
Activity
Tell it back
Your child explains, in their own words, why we use repeat. Three minutes.
Steps
- Write "Forward, Forward, Forward, Forward, Forward, Forward" on paper. Ask "Is there a shorter way to write this? Show me."
- Ask "Why is it good to write repeat?" and "What goes inside the repeat, and what goes outside?" Do not give the answer.
- Write down what your child says in their own words.
Keeping a log of the activity is for registered learners. Register to do this.
Like what you see?
Register for free to answer the quick checks, do the activities and save your work. Your work is saved on your device and syncs to your account.