Advertisement
Blessing988

Untitled

Mar 29th, 2020
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. #Superclass
  2. class Store( ):
  3.  
  4.     def __init__(self):
  5.         self.owner = "Boris"
  6.  
  7.     def exclaim(self):
  8.         return "I'm defined in the superclass!"
  9.  
  10. #Subclass of Store
  11. class HardwareStore(Store):  #Inheriting from Store SuperClass
  12.     pass
  13.  
  14. home_depot = HardwareStore( ) #Instantiating an instance
  15.  
  16. print(home_depot.owner) #Accessing the "owner" attribute
  17.  
  18. print(home_depot.exclaim( )) # Invoking the exclaim instance method
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement