Learning Goals 3 min
By the end of this lesson you will be able to:
- Drop blocks inside the mouth of a
repeat (10)c-block. - Replace a stack of repeated blocks with one loop that does the same job.
- Change one number and predict how the result will change.
Warm-Up 7 min
Your routine has a beat. But look at the stack that produces it — the same two blocks, over and over. Want twenty beats instead of four? That is thirty-six more blocks to drag.
Quick-fire puzzle
Faiz built this. How far does the cat travel, and how many blocks did he have to drag?
when flag clicked
move (10) steps
move (10) steps
move (10) steps
move (10) steps
move (10) steps
Reveal the answer
Fifty pixels, from five blocks he had to drag one at a time. Now imagine he wanted a hundred moves — that is a hundred drags, and a script too tall to fit on the screen.
Today’s block does the same job in three blocks, however many repeats you want.
New Concept — the repeat c-block 15 min
Think of repeat (10) as a megaphone for blocks. Whatever you put inside its mouth gets shouted out ten times. You write the instruction once; the computer does the repeating.
Blocks reference
| Block | Category | What it does |
|---|---|---|
repeat (10) | Control | Runs whatever is inside its mouth that many times. The number is editable. |
move (10) steps | Motion | An old friend — but now it goes inside something. |
turn cw (15) degrees | Motion | Also an old friend. Put a turn inside a loop and you can trace shapes. |
A block with a mouth
Every block you have met so far has been a flat bar. This one is shaped like the letter C, with a gap in the middle. That gap is called the mouth, and blocks dropped into it become the loop’s body.
when flag clicked
repeat (5)
move (10) steps
end
Reading a loop out loud
The best way to check a loop is to narrate it: “five times, do this: move ten steps.” If your sentence makes sense, the loop probably does too.
Inside or outside?
This is the decision people get wrong. A block inside the mouth happens every time round. A block below the C happens once, after all the repeats are finished. Same blocks, very different results.
Why it matters
Loops are everywhere in coding. Flapping wings, falling apples, the twelve marks on a clock face — all loops. This is the simplest one, and it will be the engine of half your projects from here on.
Worked Example — the cat traces a square 15 min
Four sides, four corners, and a pattern that repeats — the perfect first loop.
Step 1 — Build one side by hand
Reset the cat to the centre facing right, then build a move and a turn — one side and one corner of the square.
when flag clicked
move (120) steps
turn cw (90) degrees
Step 2 — Spot the pattern
Click the flag four times. The cat traces a square, one corner per click. That repetition is exactly what the loop is going to take over.
Step 3 — Fetch the loop
From Control, drag repeat (10) into an empty part of the Script Area. Notice its shape — there is a gap in the middle waiting to be filled.
Step 4 — Feed the mouth
Drag your move and turn blocks into the gap. The C stretches to fit them. Change the 10 to a 4, then snap the whole loop under the hat.
when flag clicked
repeat (4)
move (120) steps
turn cw (90) degrees
end
Step 5 — Run it, and see the problem
Click the flag. The cat appears to twitch and stop. All four sides really were drawn, far too fast to follow — the same invisibility problem you met last lesson.
Step 6 — Put a wait inside the mouth
Drag wait (0.5) seconds into the loop, below the turn. Now each side takes half a second and the square draws itself in front of you.
when flag clicked
repeat (4)
move (120) steps
turn cw (90) degrees
wait (0.5) seconds
end
Step 7 — Try it outside instead
Drag the wait out of the mouth and drop it below the whole C. Run it again: the square is instant, and then the script sits still for half a second doing nothing.
Same block, same number, completely different behaviour — decided only by whether it sits inside the mouth. This is the single most important thing to understand about loops.
Step 8 — Change one number
Set the repeat to 8 and the turn to 45. The cat now traces an octagon. Try 3 and 120 for a triangle. The loop never changed shape — only its numbers did.
What changed: you can now describe a pattern once instead of building it out by hand, which means your scripts stop growing every time your ideas do.
The full assembled stack (your reference)
when flag clicked
repeat (4)
move (120) steps
turn cw (90) degrees
wait (0.5) seconds
end
Try It Yourself — three small builds 12 min
Goal: Make the cat hop ten times across the stage, slowly enough to count out loud.
when flag clicked
repeat (10)
move (30) steps
wait (0.3) seconds
end
Think: count along as it runs. Ten hops of thirty is three hundred pixels — so the cat should end up against the right-hand edge.
Goal: Give the cat a wiggle it can hold for ten beats — a dance on the spot rather than a journey.
when flag clicked
repeat (10)
turn cw (15) degrees
wait (0.1) seconds
turn ccw (15) degrees
wait (0.1) seconds
end
Think: each pass turns one way and straight back, so the cat never actually goes anywhere. That is a dance step rather than a journey — and it is only six blocks.
Mini-mission: trace a triangle. A square needed four sides and 90-degree corners. Work out what a triangle needs, then build it with a loop.
It works if: the cat traces a closed triangle and finishes facing exactly the way it started. Use one loop, and stay within 8 blocks.
Think: by the end of any closed shape the cat has turned all the way round once — a full 360 degrees. Share that between three corners and you have your answer.
Mini-Challenge — countdown, then go 5 min
“Inside or outside?”
Build a script where the cat counts down on the spot, and only after the counting is finished does it set off across the stage. Getting this right depends entirely on where you put things.
It works if:
- One flag click runs everything.
- The counting is visible and happens several times over.
- The cat stays put until the counting has completely finished.
- The journey happens exactly once, not once per count.
Reveal one valid solution (teacher)
when flag clicked
repeat (3)
say [Tick] for (0.5) seconds
wait (0.5) seconds
end
say [Go!] for (1) seconds
move (200) steps
The say and the move sit below the C, so they run once. The classic error is dragging them inside the mouth, which makes the cat announce and travel three separate times — a very visible mistake and a good one to make.
Recap 2 min
The repeat block is your first c-block — a block with a mouth. Whatever sits inside that mouth runs over and over; whatever sits below the C runs once at the end. The number says how many times, not how long, so without a wait inside the whole loop finishes in a single frame. And changing one number changes everything, which is exactly why loops are worth having.
- repeat (block)
- A Control c-block that runs whatever is inside its mouth a set number of times.
- C-block
- A block shaped like the letter C, with a mouth that holds other blocks.
- Mouth
- The gap inside a c-block. Blocks here repeat; blocks below the C do not.
- Loop body
- The blocks inside the mouth — the part that gets repeated.
Homework 1 min
One loop, three shapes. Build a square with a loop, then change only the numbers to make two more shapes.
- Build the square loop from the Worked Example.
- Change the numbers to make a triangle, and write down what you used.
- Change them again to make a hexagon — six sides.
- Screenshot all three versions, or one version with your numbers written beside it.
when flag clicked
repeat (4)
move (120) steps
turn cw (90) degrees
wait (0.5) seconds
end
Bring back next class:
- Your screenshots, and the numbers you used for each shape.
- Your answer to: “Multiply the number of sides by the turn angle for each of your shapes. What do you always get, and why?”
Heads up for next class: SCR-L01-20 introduces forever — a loop with no number at all, which raises an obvious question about how it ever ends.