←Previous page

13TURTLE DRAWING · SHAPES

Loops draw shapes.

A square is the same two steps four times. A for loop repeats them for you.

IN REAL LIFE

Same steps, new shape.

Shapes hide repeated steps. Look around you.

Running around a field

Run one side, turn at the corner. Do it 4 times and you are back.

Drawing a star by hand

The same line and the same sharp turn, 5 times.

A flower

The same petal again and again, turned a little each time.

LOOK FIRST

How loops make shapes.

Repeat the side

A square is "forward, turn 90" repeated 4 times.

360 ÷ sides

All the turns add up to 360. Triangle: 120. Hexagon: 60.

Circles too

circle(50) draws a circle. 50 is the radius: middle to edge.

LOOK FIRST

Read it line by line.

A square on the left, a flower on the right.

for i in range(4):Repeats the lines below it 4 times.
t.forward(100)Walks one side.
t.left(90)Turns one corner. 4 × 90 = 360, so the square closes.
for i in range(8):The outer loop: 8 petals.
for j in range(4):The inner loop draws one square.
t.forward(60)One side of the square.
t.left(90)One corner of the square.
t.left(45)After each square, turn a little: 8 × 45 = 360.

A shape trick: For a shape with equal sides, turn 360 ÷ the number of sides each time.

RUN IT

PyBot repeats three sides.

Guess first. Then run real Python and check.

1

Guess the result

import turtle t = turtle.Turtle() for i in range(3): t.forward(150) t.left(120)

What shape will the turtle draw?

shapes.pyREAL PYTHON
OUTPUT
Ready. Press Run Python.
Python runs here thanks to Pyodide ♥

Pyodide 314.0.3 runs CPython in your browser with WebAssembly.

Open-source under the Mozilla Public License 2.0. License

Now change one thing: Change 3 to 6 and 120 to 60, then run again. What shape do you get?

YOUR TURN

Count the sides.

Try each tiny question. A wrong answer becomes something to review.

0Completed
13Not tried
0Review
01

Shapes in real life

A loop repeats the same steps again and again.

Which one is a loop that makes a shape?

02

Name the shape

for i in range(4): t.forward(80) t.left(90)

What shape appears?

03

Count the sides

for i in range(5): t.forward(60) t.left(72)

How many sides does the shape have?

04

Pick the turn

for i in range(6): t.forward(70) t.left(___)

PyBot wants a hexagon: 6 equal sides.

Which number goes in the blank?

05

A sharp turn

for i in range(5): t.forward(150) t.right(144)

What shape appears?

06

Does it close?

for i in range(4): t.forward(80) t.left(60)

Does the turtle draw a closed square?

07

A round one

t.circle(50)

What does the turtle draw?

08

A loop inside a loop

for i in range(3): for j in range(4): t.forward(40) t.left(90) t.penup() t.forward(60) t.pendown()

How many squares appear?

09

Where does it end?

for i in range(3): t.forward(100) t.left(120)

Where is the turtle after the triangle?

10

Fix PyBot's code

PyBot wants a purple hexagon with 6 sides, but the turn is wrong.

Goal drawingYour drawingOUTPUT

11

Fix PyBot's code

PyBot's star is missing one line. Fix how many times the loop runs.

Goal drawingYour drawingOUTPUT

12

Fix PyBot's code

PyBot draws 6 squares for a flower, but they all land on top of each other. Turn after each square.

Goal drawingYour drawingOUTPUT

Your work is saved here.

Want a fresh start? Clear only this page.

!
BIG IDEA

A loop turns steps into shapes.

Repeat "forward, turn" once per side, and turn 360 ÷ sides each time. A loop inside a loop repeats whole shapes.