▶ TrainingGet Pro
All tools & lessonsAll toolsAllGet the appApp
Learning departments Music, Maths, Cookery, Programming and Art are open – explore →

Block coding lesson 12: Repeat inside repeat

UK version. UK school years and UK spelling. · US version of this lesson

A repeat can go inside another repeat. If the outer one runs 3 times and the inner one 4 times, the inner blocks run 3 × 4 = 12 times. A complete 35-minute block coding lesson (Years 3–4, KS2), from Unit 4: Repeat. Myrtle the Turtle runs right here in your browser – nothing to install.

Time
35 minutes + 15 min homework
Year
Years 3–4, KS2 (ages 7–9)
You need
A computer or tablet, squared paper and a pencil
Marked
Instantly, with explanations

For parents: how to use this lesson

You don't need to know anything about coding. The lesson explains each step on screen, the way Mr Babbage, our Head of Computing, likes it: watch Myrtle first, then have a go. Programs are made from blocks – no typing – and every answer is marked straight away.

  1. Before the screen: Make a necklace pattern: repeat 3 times (repeat 2 times red bead, then a blue bead).
  2. Press Start the lesson below and watch the worked examples together. Press Run and say what each block does before Myrtle does it.
  3. Let your child do the practice on their own. When Myrtle goes the wrong way, that's a clue, not a failure – press Run again and watch which block it is on.
  4. Finish with the talk question: “How many times does a block run when it is inside two repeats?”
  5. Later that day or the next day: the homework (15 minutes), then a practice test.

Watch out for

  • Adding the counts (3 + 4) instead of multiplying. The inner loop runs completely every time the outer loop goes round: 4 + 4 + 4.
  • Putting the move between shapes inside the inner repeat. It belongs in the outer repeat, after the inner one.

Miss Lovelace's tip for home: ask your child to be Myrtle. Read out the blocks and let them walk it on the floor. If they can act it out, they understand it.

What your child will learn

We are learning to put a repeat inside a repeat.

Success looks like

  • I can put a repeat inside a repeat.
  • I can work out how many times an inner block runs.
  • I can draw patterns of shapes.

Key words

nested loop · inner · outer · pattern

The big ideas (for the adult)

A repeat can go inside another repeat. If the outer one runs 3 times and the inner one 4 times, the inner blocks run 3 × 4 = 12 times.

Make the inner repeat draw one shape, and the outer repeat move or turn before the next shape.

A worked example

repeat 3 times
    repeat 4 times
        move forward 2
        turn left 90°
    end
    move forward 2
end

Press Start the lesson to watch the turtle run it.

The lesson, step by step

35 minutes in 5 parts
PartTimeHow it is checked
Starter5 minMarked by Classfern
Teach8 minWatch, talk and try
Worked example and try it7 minMarked by Classfern
Practice10 minMarked by Classfern
Plenary5 minMarked by Classfern + self-check

The lesson

It runs here on the page. No sign-up and no names – progress is kept only in this browser. Each visit picks a new mix of questions.

Homework

15 minutes: 5 questions – work out what Myrtle does, then build or fix a program – and a short reflection. New questions every time, all marked instantly. Away from the screen: make a necklace pattern: repeat 3 times (repeat 2 times red bead, then a blue bead).

Practice tests

All computing practice tests · All 18 block coding lessons

Curriculum

National curriculum in England, computing, key stage 2: pupils should be taught to use sequence, selection, and repetition in programs; work with variables and various forms of input and output; and to use logical reasoning to explain how some simple algorithms work and to detect and correct errors in algorithms and programs.

Contains public sector information licensed under the Open Government Licence v3.0.

Our lessons, blocks and questions are our own. They are not written or endorsed by any government department, testing agency or exam board.