Change Contents of the Bubble
Welcome to CS1315. Click on the python to add comments.

Looking for the book? They have it at the Engineer's Bookstore at 748 Marietta St NW. Here is there website: http://www.engrbookstore.com/ - Monica

Hotspots: Slides and CodeTA CornerComments?AnnouncementsFAQStatic Webspace
View this PageEdit this Page (locked)Uploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

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