The presentation of a spiral-drawing program culminates in this program.
1 2 3 4 5 6 7 8 9 10 11 12 13
from turtle import * from math import * pensize(10) pencolor("blue") penup() radius = 20 goto(radius,0) pendown() for i in range(1,300): newangle = 2*i*pi/100 goto( radius*cos(newangle), radius*sin(newangle) ) radius = radius + 1
Two significant changes from the earlier
circle-drawing program are seen above.
radius is redefined
to be one unit larger, each time variable
i steps through its sequence
of numbers. Second, the sequence of numbers
is not 1-100, but instead 1-299, even though
the angle variable
calculation is in terms of 1/100th of a
full sweep around the circle. In effect, the
larger sequence 1-299 amounts to going about
three times around the circle. Drawing three
times around a circle would not be needed to
draw a circle, but because the radius is
increasing, the program draws a spiral.
Two interesting pointers related to this example are: