Answer: Turtle Challenge #354

Here’s what the code from Turtle Challenge #354 draws. This picture was made by running the code for real.

The drawing made by turtle challenge 354.
What the turtle drew.

The answers

What shape does the shape function draw? A square (4 sides, turning 90 degrees each time).

How many of those shapes will you see? 18 of them, spun around the middle.

How many lines does the turtle draw altogether? 18 × 4 = 72 lines.

How the code works

The function shape is a new word we taught Python. The main loop uses it 18 times, turning 20 degrees in between, so the squares spin round in a ring.

import turtle

t = turtle.Turtle()
t.speed(0)
colours = ["purple", "turquoise", "orange"]

def shape(size):
    for side in range(4):
        t.forward(size)
        t.left(90)

for i in range(18):
    t.pencolor(colours[i % 3])
    shape(80)
    t.left(20)

t.hideturtle()
turtle.done()

Try it: Change shape(80) to shape(i * 5). What happens?