Lesson 06 · 60 minutes

Doing It Again

Loops, and why repetition is not copy-paste

Today's goal

Use a repeat block to make a square, then change the square's size by editing one number.

Ideas in this lesson

Sense → Think → Do

THINK, compressed. The same behaviour in fewer instructions.

How the session runs

  1. Build a square the long way: eight blocks, drive-turn-drive-turn-drive-turn-drive-turn. Run it.
  2. Now build it with a repeat block: repeat 4 times, containing drive and turn. Two blocks inside one.
  3. Compare the robot language. Same behaviour, a third of the lines.
  4. Change the repeat count to 3. Predict the shape before running it.
  5. Change the drive distance to 2 rooms. One number, bigger square.
  6. Put a repeat inside a repeat and see what happens. Predict first.

Sample program

A square. P 4 starts 'repeat four times', Q ends it. Everything between them happens four times.

V 5
P 4
F 900
L 350
Q

Paste it into the Workshop's Robot language box, then press Text → blocks to see it as blocks — or just send it straight to the robot.

Try this

When it goes wrong

What you seeWhat it means
Blocks land after the repeat instead of inside itTap the dotted area inside the repeat block first, then tap the palette. The dotted area glows when it is aimed.
The square drifts into a spiralTurns are not exactly 90°. Back to calibration — or use it: a deliberate spiral is a fine challenge.
Notes for the grown-up

The hexagon challenge is a good trap: quarter turns cannot make 60°, so they have to notice the limitation and ask for timed spins instead. Let them hit the wall before offering the tool.

← Your First ProgramMaking Decisions →