Page 128 - Programming With Python 3
P. 128

An Introduction to STEM Programming with Python — 2019-09-03a                              Page 115
            Chapter 9 — Object Oriented Programming

             27|          # return true/false if successful
             28|          if student in self.enrolled:
             Free
             29|              self.enrolled.remove(student)
             30|              return True
             31|          else:
             32|              return False
             33|
             34|
             eBook
             35|  buis3100 = Class("database")
             36|
             37|  for x in (123, 56, 43, 435345, 54645, 8787, 213123):
             38|      print('register', x, buis3100.register(x))
             39|  print(buis3100)
             40|  print(buis3100.enrolled)
             Edition
             41|
             42|  print('drop 43', buis3100.drop(43))
             43|  print(buis3100)
             44|  print(buis3100.enrolled)


                    register 123 True
            Please support this work at
                    register 56 True
                    register 43 True
                    register 435345 True
                    register 54645 True
                                  http://syw2l.org
                    register 8787 True
                    register 213123 True
                    The database class has 7 students, and has 23 seats available.
                    [123, 56, 43, 435345, 54645, 8787, 213123]
                    drop 43 True                                               Free
                    The database class has 6 students, and has 24 seats available.
                    [123, 56, 435345, 54645, 8787, 213123]



                                                                   eBook
            Inheritance



            NEED TO ADD
            Extending one class from another
                                                                Edition
            call base class method (init)








            Copyright 2019 — James M. Reneau Ph.D. — http://www.syw2l.org — This work is licensed
            under a Creative Commons Attribution-ShareAlike 4.0 International License.
   123   124   125   126   127   128   129   130   131   132   133