lab11 - return self.sentence def getWords(self): sentence =...

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

View Full Document Right Arrow Icon
import math import cTurtle class Planet: def __init__(self, iname, irad, im, idist, imoon): self.moonList = [] self.name = iname self.radius = irad self.mass = im self.distance = idist self.moon = imoon def getName(self): return self.name def getRadius(self): return self.radius def getMass(self): return self.mass def getDistance(self): return self.distance def getMoon (self): return self.moon def addMoon(self): self.moonlist.append(imoon) def getNumMoons(self): return len(moonlist) def getMoonList (self): return self.moonList def getCircumference (self): circumference = 2*pi*(self.getRadius())**2 return circumference class sentence: def __init__(self, isentence): self.sentence = isentence def getSentence(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
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: return self.sentence def getWords(self): sentence = self.sentence return sentence.split() def getLength(self): sentence = self.sentence return len(list(sentence)) def getNumWords (self): sentence = self.sentence return len(sentence.split()) def __str__ (self): return self.sentence def __getitem__ (self, index): itemList = self.sentence.split() return itemList.__getitem__(index) def __add__ (self, newObject): object1 = self.sentence.split() object2 = newObject.sentence.split() return sentence(object1 + object2) def __include__(self, newObject): if newObject in self.sentence: return True else: return False...
View Full Document

Page1 / 2

lab11 - return self.sentence def getWords(self): sentence =...

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

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