|Welcome to CS1315. Click on the python to add comments.|
|This page removed for FERPA compliance|
# A chameleon is a type of turtle that knows how to change color.
# Create/initialize a chameleon. It's green all over by default.
def __init__(self, world):
Turtle.__init__(self, 200, 200, world)
# REMOVEDw a chameleon changes its color. It has to change the color
# of its body parts, its shell, and the slime it leaves behind
# as it moves (i.e. the color of its pen).
def changeColor(self, color):
pen = self.getPen()
# A simulation of a lone kaleidoscopic chameleon! It moves at random for a
# specified number of steps, waiting for a half second before moving again.
# Create a world containing one chameleon, called ch and a bunch of colors.
world = makeWorld()
ch = Chameleon(world)
colors = [red, yellow, green, cyan, blue, magenta, black, lightGray, darkGray]
# Have the chameleon keep doing its thing for the specified number of steps
for step in range(numSteps):
# Change heading at random, move, change color, and finally rest.
Links to this Page