{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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 Document Right Arrow Icon
return self.father def getMother (self): return self.mother def getChildren (self): return self.children def setName (self, name): self.name = name return self.name
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.

{[ snackBarMessage ]}