Poly function
import time
# Draw a repeating geometrical figure with specified side length and
# turning through specified angle.
#
# Rewritten for JES from a LOGO program in Abelson and DiSessa's
# "Turtle Geometry" (1980, p. 15)
#
# Note that this program is deliberately written with an infinite loop.
# It will run for ever, so you have to stop it by pressing the stop button.
#
# Experiment by varying the value of angle. (Changing side will scale
# the shape and stop it from distorting if the turtle runs up against
# the edge of the world. Changing the angle will affect the shape.)
def poly(side, angle):
world = makeWorld(640, 480)
turtle = makeTurtle(world)
while 1: #In other words, repeat FOREVER!!
forward(turtle, side)
turn(turtle, angle)
forward(turtle, side)
turn(turtle, 2*angle)
time.sleep(0.5) # Delay half a second so we can watch it draw
Link to this Page