Page 243 -
P. 243

custom data objects




                              Here is the code for the now defunct Athlete class. In the space provided below, rewrite this
                              class to inherit from the built-in list class. Call your new class AthleteList. Provide a
                              few lines of code to exercise your new class, too:
                              class Athlete:
                                  def __init__(self, a_name, a_dob=None, a_times=[]):
                                      self.name = a_name
                                      self.dob = a_dob
                                      self.times = a_times

                                  def top3(self):
                                      return(sorted(set([sanitize(t) for t in self.times]))[0:3])


                                  def add_time(self, time_value):
                                      self.times.append(time_value)


                                  def add_times(self, list_of_times):
                                      self.times.extend(list_of_times)
              Write your new
              class code here.

























              Exercise your
              code here.






                                                                                      you are here 4    207
   238   239   240   241   242   243   244   245   246   247   248