🧩 Block coding, Grade 5 · session 2 of 14 · 60 minutes · free

Loops: repeat instead of copying

When you see the same steps again and again, a loop can do them for you. A repeat block runs the blocks inside it as many times as you say: less dragging, fewer bugs.

🎯 Practice mode🖨 Print a worksheet

A complete lesson · 60 minutes

Teach it, see it, practise it, all on this page.

Open this page with your learner and work down it, or press Teach this lesson to go through it one step at a time on a big screen. Every section has something to do.

See the teacher's plan
  1. Warm-up4 min
  2. Patterns7 min
  3. The repeat block7 min
  4. Saving blocks7 min
  5. code.org practical: puzzles 6–918 min
  6. Activity 14 min
  7. Activity 24 min
  8. Activity 33 min
  9. Quiz5 min
  10. Set the project1 min

By the end you can

  • Spot a repeating pattern in a path
  • Use repeat n times with the right number
  • Put several blocks inside one loop

Before you start

  • Algorithms and sequences (session 1)

Have ready

  • code.org open in another tab
  • Squared paper and coloured pencils

Grade 5 · ages 9 to 11 · beginner

Warm-up · think first

Clap, stamp, clap, stamp, clap, stamp. How can you say that faster?

Show the answer

"Clap, stamp, three times!" That is a loop: say the pattern once and how many times to repeat it.

Teacher tip: Do it together, then invent a pattern and say it as a loop.

More warm-ups for every class →

Part 1 of 3 · learn, see, practise

Spot the pattern

A loop repeats a set of steps.

First spot the pattern: which steps come again and again?

Then count how many times the pattern repeats.

Example 1

Byte must reach the star. What repeats?

  1. The path is straight: 5 squares.
  2. The same block, move forward, happens 5 times.
  3. So repeat 5 times: move forward.

Answer: repeat 5 times: move forward

Practise it

Start with the warm-up and go as far as you can. The stretch questions are meant to be hard.

Warm-up

Warm-up

Core

Stretch 🔥

Answers (for the teacher)
  1. 5
  2. clap
  3. 3
  4. 3

Part 2 of 3 · learn, see, practise

The repeat block

Put the repeating blocks inside the repeat block's mouth.

Change the number to how many times it should run.

Blocks after the loop run once, when the loop is finished.

Example 1

Turn the staircase into a loop.

when runrepeat 3 timesmove forwardturn right ↻move forwardturn left ↺
  1. The pattern is move forward, turn right, move forward, turn left.
  2. It happens 3 times.
  3. Put those 4 blocks inside repeat 3 times.

Answer: repeat 3 times: move forward, turn right, move forward, turn left

Practise it

Start with the warm-up and go as far as you can. The stretch questions are meant to be hard.

Warm-up

Core

Core

Stretch 🔥

Answers (for the teacher)
  1. 4
  2. 6
  3. same way
  4. 3

Part 3 of 3 · learn, see, practise

Loops save blocks

Without a loop the staircase needs 12 blocks. With a loop it needs 5: the repeat block and the 4 inside it.

Fewer blocks means less to drag and fewer places for bugs to hide.

Count the repeat block itself as one block.

Example 1

How many blocks does the loop save on the staircase?

when runrepeat 3 timesmove forwardturn right ↻move forwardturn left ↺
  1. Without a loop: 4 blocks × 3 = 12.
  2. With the loop: 1 repeat + 4 inside = 5.
  3. 12 − 5 = 7 blocks saved.

Answer: 7 blocks

Practise it

Start with the warm-up and go as far as you can. The stretch questions are meant to be hard.

Warm-up

Core

Core

Stretch 🔥

Answers (for the teacher)
  1. 5
  2. 2
  3. 3
  4. 8

Watch out

Common mistakes

Putting blocks under the loop instead of inside it

Inside means in the loop's mouth, indented; check the block moves with the loop when you drag it.

Counting the pattern wrong

Trace the path with a finger and count each time the pattern ends.

Forgetting the blocks after the loop

Some mazes need one or two extra blocks after the loop finishes.

🖥️ Practical · puzzles 6–9

Classic Maze, puzzles 6 to 9

Now try it for real. Open the puzzles in a new tab and share that tab, then come back here for the activities and quiz.

▶ Open the puzzles on code.org ↗

Step by step

  1. Open the link; it starts at puzzle 6, where the repeat block appears.
  2. Before dragging, say the pattern out loud: "move, move, move… that's repeat!"
  3. Drag the repeat block in first, then put the moves and turns inside its mouth.
  4. Change the number to how many times; press Run.
  5. Look at the block count: can you solve it with fewer blocks?

Teacher tips

  • If the loop runs too far, the number is too big: count the squares again.
  • Blocks below the loop run once, after it finishes.
  • Ask: which blocks are inside the loop, and which are outside?

code.org is a free, non-profit coding site. Its puzzles open in your browser; an account is optional and only saves progress.

Class activity 1 of 3

Dance loop

Make up a dance with a loop and teach it to the learner.

  1. Choose 3 moves: for example clap, hop, spin.
  2. Say it as a loop: repeat 4 times clap, hop, spin.
  3. Do it together.
  4. The learner writes their own dance loop and you follow it.

🙌 No screen needed: play it together, step by step.

Class activity 2 of 3

Loop or no loop?

Count the blocks. Type the number for each.

  1. Read the program.
  2. Count the blocks with a loop.
  3. Type the number.

Answers (for the teacher)
  1. 2
  2. 6
  3. 2
  4. 6

Class activity 3 of 3

Pattern detective

Find the repeating pattern and say how many times it repeats.

  1. Read the list.
  2. Find the part that repeats.
  3. Type how many times it repeats.

Answers (for the teacher)
  1. 3
  2. 2
  3. 4
  4. 5

After class · project

Loop art

Draw a pattern on squared paper using a loop program.

What to make: A repeating pattern made from a loop.

Stretch: Put a loop inside another loop to draw rows.

How it is marked

Look forDone well when
LoopThe pattern repeats the right number of times
CountingBlock counts with and without the loop are right

Project template

Copy it onto paper or print the practice sheet.

My loop: repeat ___ times:
   step 1: ______
   step 2: ______
My drawing (stick it here)
Blocks with the loop: ___  Without: ___

Homework

Practise at home

Try each on paper, then tap to see the answer and working. Or print the practice sheet.

  1. Write a loop for: hop, hop, hop, hop, hop, hop.

    repeat 6 times: hop

  2. repeat 3 times: move forward, move forward. How many squares?

    6

  3. A 2-block pattern repeats 5 times. Blocks without a loop?

    10

  4. Same pattern with a loop. How many blocks, counting the repeat?

    3

🔥 Challenge round · finished early?

The hardest questions of the lesson, no notes

Cover the notes and try these from memory. They are meant to make you think hard: draw, try small cases, and check your answer.

Stretch 🔥

Stretch 🔥

Stretch 🔥

Answers (for the teacher)
  1. 3
  2. 3
  3. 8

🧠 Think-hard question

Solve a puzzle with a loop and then with no loop; count the difference.

Talk it through or use the drawing board. There is more than one way to get there.

Quiz · 8 questions

Final quiz: check what you learned

Pick an answer to see if it is right and why. Your best score is saved on this device.

1What does a loop do?
Show the answer

Repeats blocks. A loop runs the blocks inside it again and again.

2repeat 4 times: move forward. Byte moves …
Show the answer

4 squares. One move, four times.

3How many times must move forward repeat here?
Show the answer

5. Count the squares to the star.

4repeat 2 times: move forward, move forward. Byte moves …
Show the answer

4 squares. 2 moves inside, done twice.

5Which pattern repeats on this staircase?
Show the answer

move, turn right, move, turn left. Trace one step of the stairs.

6Blocks after a loop run …
Show the answer

once, after the loop. The loop finishes, then the program carries on.

7A loop saves blocks because …
Show the answer

you write the pattern once. And say how many times.

8repeat 4 times: turn right. Byte ends up facing …
Show the answer

the same way. 4 right turns make a full circle.

🖨 Print what we learned

Make a worksheet from this lesson

Pick what to practise, then print it or choose Save as PDF in the print window to download it.

Include
Options

For parents and teachers

The 60-minute lesson plan

Use it as it is, or stretch any part over two sessions. Each row links to the part of the page you need.

TimePartThe teacherThe learner
0–4 minWarm-upAsk the warm-up question; let them act it out.Guess, then explain.
4–11 minPatternsExplain with the comic, reveal the example, then the practice.Practise; try the star question.
11–18 minThe repeat blockExplain, trace the example with a finger on the screen, then the practice.Practise.
18–25 minSaving blocksExplain and show the example, then the practice.Practise.
25–43 mincode.org practical: puzzles 6–9Share the code.org tab. Let the learner drive; ask them to say each block out loud before Run.Solve the puzzles; say the plan first.
43–47 minActivity 1An unplugged game: get the learner moving.Play the robot.
47–51 minActivity 2Do the first item together.Finish the activity.
51–54 minActivity 3Quick puzzle; set the rest as homework if time is short.Solve and check.
54–59 minQuizRead each question aloud; the learner taps and reads why.Answer and explain.
59–60 minSet the projectShow the template and agree a day to share it.Start the project.

Questions to ask

  • How do you know when to use a loop?
  • Which blocks go inside the loop?
  • How many blocks did your loop save?

If it feels hard

Colour the repeating part of the path on paper before building the loop.

If it feels easy

Solve a puzzle with a loop and then with no loop; count the difference.

FAQ

Loops: repeat instead of copying: questions

What is a loop in coding for kids?

A block that repeats the blocks inside it a set number of times, so you write a pattern once instead of copying it.

What is the difference between repeat and repeat until?

Repeat runs a fixed number of times; repeat until keeps going until something happens, like reaching the goal. That is the next lesson.

Which code.org puzzles practise loops?

In the Classic Maze, the repeat block appears around puzzle 6.

Start a conversation

Want a teacher to take this class?

Tell us the learner's age and level. A teacher from our network teaches with these lessons; we confirm timing and price first.

  • Tell us the learner’s age or grade and goals
  • We’ll suggest a suitable class or learning path
  • We’ll confirm format, timing and fees with a parent or guardian

For a child’s class, please have a parent or guardian send the enquiry. Avoid sharing passwords or sensitive personal details.

We’ll use your details only to respond to this request.

Chat on WhatsApp
Esc

Try