Learning Goals 3 min
By the end of this lesson you will be able to:
- State the polygon rule out loud: to draw a shape with N sides, repeat N times — each repeat is "move forward, then turn 360 ÷ N degrees".
- Build the four classic shapes — triangle, square, hexagon, octagon — by changing only two numbers in the same stack.
- Use () / () inside the turn block so the angle is calculated by Scratch instead of by you in your head.
Warm-Up — drawing a square the long way 7 min
Here's how you'd draw a square without a loop. Four sides, four turns, eight blocks.
when flag clicked
erase all
pen down
move (100) steps
turn cw (90) degrees
move (100) steps
turn cw (90) degrees
move (100) steps
turn cw (90) degrees
move (100) steps
turn cw (90) degrees
pen up
Click the flag (mentally). The cat draws a square. Now look at the stack. What's repeating?
Reveal the answer
The pair move (100) steps + turn ↻ (90) degrees appears four times in a row. Identical pairs. Stacked. That's the universal sign that a loop should be doing the work instead of you.
One repeat (4) replaces all eight of those repeated blocks with two. Shorter, clearer, and — most importantly — easy to change to a triangle, a pentagon, or a hundred-sided shape.
Today's question: where does the 90 come from, and what number replaces it for a triangle? For a hexagon?
New Concept — the 360-degree rule 15 min
Imagine you're a cat walking around a square shape. You walk one side, turn, walk another, turn, walk another, turn, walk the last, turn — and you're back where you started, facing the way you started.
How much have you turned in total? You've gone all the way around — one full circle — 360 degrees.
You took 4 turns, all equal. So each turn was 360 ÷ 4 = 90 degrees. That's where the 90 in the warmup came from. It wasn't magic. It was 360 divided by 4 sides.
The rule, written out
This works for any regular polygon (any shape with all-equal sides and all-equal angles):
repeat (4)
move (100) steps
turn cw (90) degrees
end
Swap the 4 and the 90 to draw a different shape. The two numbers always link by the rule turn = 360 ÷ sides:
The four classic shapes
- Triangle — 3 sides. Turn = 360 ÷ 3 = 120. Use repeat (3) with turn ↻ (120) degrees.
- Square — 4 sides. Turn = 360 ÷ 4 = 90. Use repeat (4) with turn ↻ (90) degrees.
- Hexagon — 6 sides. Turn = 360 ÷ 6 = 60. Use repeat (6) with turn ↻ (60) degrees.
- Octagon — 8 sides. Turn = 360 ÷ 8 = 45. Use repeat (8) with turn ↻ (45) degrees.
Let Scratch do the maths
Instead of computing 360 ÷ N in your head, you can drop the () / () divide operator into the turn block:
repeat (6)
move (50) steps
turn cw ((360) / (6)) degrees
end
This is the safer version. If you later change the 6 in repeat (6) to an 8, you also have to change the 6 inside the divide to an 8 — but at least the rule is written down right there in the stack, where you can see it.
Even better: store the number of sides in a variable called sides. Then the same stack can draw any polygon — just change the variable. (You'll see this trick in SCR-L04-13 when My Blocks meet Pen.)
Worked Example — four shapes, four positions 12 min
Open Scratch. Pen extension on. We're going to draw all four classic polygons in a single project — triangle on the left, square next to it, hexagon, then octagon. Same loop skeleton each time, only two numbers change.
Step 1 — Start fresh
New project. Default cat. The cat will jump between four spots and draw a shape at each one.
Step 2 — Hat and erase
From Events: when ⚑ clicked. From Pen: erase all. Standard opener.
Step 3 — Triangle on the far left
Jump: go to x: (-180) y: (-30). pen down. Then the triangle loop:
repeat (3)
move (60) steps
turn cw ((360) / (3)) degrees
end
Close with pen up so the next jump is silent.
Step 4 — Square next to it
Jump: go to x: (-80) y: (-30). pen down. The square loop:
repeat (4)
move (60) steps
turn cw ((360) / (4)) degrees
end
pen up.
Step 5 — Hexagon
Jump: go to x: (40) y: (-30). pen down. The hexagon loop — same skeleton, just change 4 → 6:
repeat (6)
move (40) steps
turn cw ((360) / (6)) degrees
end
pen up.
Step 6 — Octagon
Jump: go to x: (150) y: (-30). pen down. Same trick, just change 6 → 8:
repeat (8)
move (30) steps
turn cw ((360) / (8)) degrees
end
pen up.
Step 7 — Run it
Click the flag. The cat zips to four spots on the Stage and draws a tidy row of shapes: triangle, square, hexagon, octagon. All four use the same loop pattern. Only two numbers differ each time — the repeat count and the side length.
Step 8 — Look at what's identical
The four shape-loops have identical structure. That's the big idea. The pattern repeat (N) + move () steps + turn ↻ ((360) / (N)) degrees draws a regular polygon for any N. SCR-L04-13 will wrap that pattern into a single custom draw polygon (N) size (S) block so you never have to type it again.
The full assembled stack
when flag clicked
erase all
go to x: (-180) y: (-30)
pen down
repeat (3)
move (60) steps
turn cw ((360) / (3)) degrees
end
pen up
go to x: (-80) y: (-30)
pen down
repeat (4)
move (60) steps
turn cw ((360) / (4)) degrees
end
pen up
What you just built: a project that proves the 360-degree rule by showing it work for four different shapes in a single click. Same loop, same maths, four different polygons.
Try It Yourself — three polygon drills 15 min
Goal: Draw a single equilateral triangle in the centre of the Stage. Side length 80 steps.
when flag clicked
erase all
go to x: (-40) y: (-30)
pen down
repeat (3)
move (80) steps
turn cw (120) degrees
end
pen up
Think: Why 120 and not 60? Because the cat turns by the outside angle of the polygon, not the inside one. The inside angle of an equilateral triangle is 60°, but the cat turns the outside angle, which is 180 − 60 = 120. Conveniently, this equals 360 ÷ 3.
Goal: Draw a regular pentagon (5 sides). Use the divide operator inside the turn so Scratch calculates the angle for you.
when flag clicked
erase all
go to x: (-40) y: (-50)
pen down
repeat (5)
move (70) steps
turn cw ((360) / (5)) degrees
end
pen up
Think: Try replacing the 5 in repeat (5) with a 7 — but leave the divide as (360) / (5). What goes wrong? The shape won't close, because the cat is turning the wrong amount for 7 sides. Both 5s have to change together. (That's why a variable for "sides" is so much safer — only one number to change.)
Goal: Draw a circle. Yes — really a circle. A circle is just a polygon with so many tiny sides that you can't see the corners any more. Use repeat (36) with sides of 10 steps each.
when flag clicked
erase all
go to x: (0) y: (-60)
pen down
repeat (36)
move (10) steps
turn cw ((360) / (36)) degrees
end
pen up
Think: Try 360 sides of 1 step each — the cat moves a tiny distance and turns a tiny angle 360 times, drawing a perfectly smooth circle. Try 5 sides of 70 steps each — a chunky pentagon. Same loop, totally different visual. The number of sides controls how smooth the curve looks. That's the deep insight Greek mathematicians used 2,500 years ago to estimate pi.
Mini-Challenge — the broken hexagon 5 min
"Priya's open shape"
Priya wants to draw a hexagon. She writes this stack:
when flag clicked
erase all
pen down
repeat (6)
move (60) steps
turn cw (45) degrees
end
pen up
She runs it. The cat draws something that looks like the start of a hexagon, but the last side doesn't meet the first one — there's a gap, and the cat ends up facing slightly off. What's wrong, and what's the rule that tells you?
Reveal one valid solution
Priya used the wrong angle. The rule is turn = 360 ÷ number of sides. For 6 sides, that's 360 ÷ 6 = 60, not 45. She probably remembered "45" from an octagon (8 sides) and reused it here without redoing the maths.
Check: total turning = 6 × 45 = 270°. That's only three-quarters of a circle, so the cat hasn't returned to its starting direction. The shape can't close — the maths forbids it.
The fix is one number:
when flag clicked
erase all
pen down
repeat (6)
move (60) steps
turn cw (60) degrees
end
pen up
6 × 60 = 360. One full circle of turning. The cat ends up facing the same way it started, the shape closes perfectly, hexagon done. If the shape doesn't close, the angles don't add up to 360 — every single time.
The safest version uses () / () so the angle is always right: turn ↻ ((360) / (6)) degrees. Now the only number Priya can get wrong is the 6, and if she does, the same wrong 6 is in both places — so the shape still closes, it's just a different shape.
Recap 3 min
You learned the single most-useful drawing rule in Scratch: a regular polygon with N sides is repeat (N) wrapped around move () steps + turn ↻ ((360) / (N)) degrees. The cat turns a total of 360° during the loop, which is exactly one full circle, which is exactly what it takes to close a shape and end up facing the start. The same skeleton draws triangles, squares, hexagons, octagons, and (with enough sides) circles. Change two numbers — sides and side length — and you have a new shape.
- Polygon
- A closed shape made of straight sides. A regular polygon has all sides and all angles equal — triangle, square, pentagon, hexagon, and so on.
- Side
- One straight edge of a polygon. In the loop, one repeat = one side + one turn at the corner.
- Turn angle
- The amount the cat rotates at each corner. For a regular N-gon, this is always 360 ÷ N. Also called the exterior angle.
- 360-degree rule
- To close a shape, the cat's total turning has to equal one full circle — 360°. Sum of all turns = 360. If it doesn't, the shape won't close.
- Divide operator
- () / () from the Operators palette. Drop it inside any number slot to make Scratch divide for you instead of doing the maths in your head.
Homework 2 min
The Shape Sampler. In one project, draw four different polygons of your choice — any sides from 3 to 12 — at four different positions on the Stage. Use the () / () trick inside every turn block so Scratch does the angle maths for you.
- Start with when ⚑ clicked and erase all.
- For each shape: go to x: () y: () to a spot on the Stage, pen down, the polygon loop, then pen up.
- Set set pen color to () to a different colour for each shape (use the picker), so you can tell them apart.
- Keep the side length small for shapes with many sides — a 12-sided polygon at 60 steps per side is huge.
- Total block count must stay under 30 (the L4 cap). Four shapes × 5 blocks each + 2 for the opener = 22. Plenty of room.
Save as HW-L4-09-Shape-Sampler.sb3. Click the flag — four shapes appear in four colours, all closed cleanly.
Bring back next class:
- The
.sb3file. - Your answer to: "Try drawing a 50-sided polygon with sides of 5 steps each. What does it look like? What does that tell you about circles?"
Heads up for next class: SCR-L04-10 uses everything from this cluster to draw a Deepavali kolam — a traditional Indian-Malaysian doorstep pattern made of nested polygons in bright colours. Practise your shape loops now; they're the building blocks.