{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# lab13 - import cTurtle import random def listSum(alist if...

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

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):

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

View Full Document
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
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}