# L-24 MCS 260 Mon 8 Oct 2010 : class Person class Person: """ An object of the class Person is either a librarian or a patron of the Library. """ def create(self,**nps): "Prompts for data if not in nps." if nps.has_key('name'): self.name = nps['name'] else: self.name = raw_input('Give your name : ') if nps.has_key('PIN'): self.PIN = nps['PIN'] else: self.PIN = input('Give your PIN : ') if nps.has_key('status'): self.librarian = nps['status'] else: answer = raw_input('Librarian ? (y/n) ') if answer == 'y': self.librarian = True else: self.librarian = False return self def show(self): "Shows info about the person." s = self.name + ' with PIN ' s += '%2d' % self.PIN if self.librarian: s += ' is a librarian' else: s += ' is a patron' print s def check(self): "Returns the status of the person." return self.librarian def change(self): "Prompts for a new PIN and status." print 'Hi ' + self.name self.PIN = input('Give new PIN : ') answer = raw_input('Librarian ? (y/n) ') if answer == 'y': self.librarian = True else: self.librarian = False