Answer: Turtle Challenge #167

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

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

The answers

What does the picture show? A sun! A gold circle with orange rays all round it.

How many rays will it have? 12 rays. t.setheading(ray * 30) points the turtle in a new direction for each ray.

Do the rays touch the circle? No. The turtle moves out 65 steps with the pen up first, which is a little further than the circle’s radius of 50, so there’s a gap.

How the code works

begin_fill() and end_fill() colour in the circle. Then each ray starts from the middle: the turtle jumps out past the edge with its pen up, then draws.

import turtle

t = turtle.Turtle()
t.speed(0)
t.pensize(4)
t.pencolor("orange")
t.fillcolor("gold")

t.penup()
t.goto(0, -50)
t.pendown()
t.begin_fill()
t.circle(50)
t.end_fill()

for ray in range(12):
    t.penup()
    t.goto(0, 0)
    t.setheading(ray * 30)
    t.forward(65)
    t.pendown()
    t.forward(80)

t.hideturtle()
turtle.done()

Try it: Can you add a smiley face to the sun?