lab13 - import cTurtle import random def listSum(alist): if...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
import cTurtle import random def listSum(alist): if len(alist)==1: return alist[0] else: return alist[0] + listSum(alist[1:]) def drawSquare(myTurtle, sideLengthLength): position=t.position() t.up() t.forward(0.5 * sideLengthLength) t.down() t.right(90) t.forward(.5 * sideLengthLength) t.right(90) for i in range (3): t.forward(sideLengthLength) t.right(90) t.forward(.5 * sideLengthLength) t.up() t.goto(position) def centeredSquare(myTurtle, sideLength): if sideLength<=1: return else: drawSquare(myTurtle, sideLength) centeredSquare(myTurtle, sideLength-20) def centeredSquare2(myTurtle, sideLength): if sideLength<=1: return else: centeredSquare2(myTurtle, sideLength - 20) drawSquare(myTurtle, sideLength) class Person: def __init__(self, mother, father): self.mother = mother self.father = father self.name = 'baby' self.children = [] if self.mother != None: mother.addChild(self) if self.father !=None: father.addChild(self) def getFather (self):
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
return self.father def getMother (self): return self.mother
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/26/2011 for the course CPS 324 taught by Professor Safa during the Spring '11 term at Dickinson.

Page1 / 3

lab13 - import cTurtle import random def listSum(alist): if...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online