Running around a field
Run one side, turn at the corner. Do it 4 times and you are back.
13TURTLE DRAWING · SHAPES
A square is the same two steps four times. A for loop repeats them for you.
IN REAL LIFE
Shapes hide repeated steps. Look around you.
Run one side, turn at the corner. Do it 4 times and you are back.
The same line and the same sharp turn, 5 times.
The same petal again and again, turned a little each time.
LOOK FIRST
A square is "forward, turn 90" repeated 4 times.
All the turns add up to 360. Triangle: 120. Hexagon: 60.
circle(50) draws a circle. 50 is the radius: middle to edge.
LOOK FIRST
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
Guess first. Then run real Python and check.
import turtle
t = turtle.Turtle()
for i in range(3):
t.forward(150)
t.left(120)What shape will the turtle draw?
PyBot's hint
Ready. Press Run Python.
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
Try each tiny question. A wrong answer becomes something to review.
Which one is a loop that makes a shape?
for i in range(4):
t.forward(80)
t.left(90)What shape appears?
for i in range(5):
t.forward(60)
t.left(72)How many sides does the shape have?
for i in range(6):
t.forward(70)
t.left(___)PyBot wants a hexagon: 6 equal sides.
Which number goes in the blank?
for i in range(5):
t.forward(150)
t.right(144)What shape appears?
for i in range(4):
t.forward(80)
t.left(60)Does the turtle draw a closed square?
t.circle(50)What does the turtle draw?
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?
for i in range(3):
t.forward(100)
t.left(120)Where is the turtle after the triangle?
PyBot wants a purple hexagon with 6 sides, but the turn is wrong.
PyBot's star is missing one line. Fix how many times the loop runs.
PyBot draws 6 squares for a flower, but they all land on top of each other. Turn after each square.
Want a fresh start? Clear only this page.
Repeat "forward, turn" once per side, and turn 360 ÷ sides each time. A loop inside a loop repeats whole shapes.