Answer: Turtle Challenge #270

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

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

The answers

What shape does the shape function draw? A triangle (3 sides, turning 120 degrees each time).

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

How many lines does the turtle draw altogether? 20 × 3 = 60 lines.

How the code works

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

import turtle

t = turtle.Turtle()
t.speed(0)
colours = ["red", "limegreen", "seagreen"]

def shape(size):
    for side in range(3):
        t.forward(size)
        t.left(120)

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

t.hideturtle()
turtle.done()

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