MIT 6.00SC | Lecture 12 | Introduction to Simulation and Random Walks
Generator Yield
We will start with the example in the previous lecture, see the code here;-
import datetime class Person(object): def __init__(self, name): #Create a person with name self.name = name try: firstBlank = name.rindex(' ') # print "__init__: firstBlank: ", firstBlank self.lastName = name[firstBlank+1:] except : self.lastName = name self.birthDay = None def getLastName(self): #returns…
View On WordPress








