Advertisement
c0d3dsk1lls

MULTI-LEVEL INHERITANCE CodedSkills.net

Aug 3rd, 2022
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.36 KB | None | 0 0
  1. #MULTI-LEVEL INHERITANCE = WHEN A DERIVED (CHILD) CLASS INHERITS ANOTHER DERIVED (CHILD) CLASS
  2. #--------------
  3. class Organism:
  4.     alive = True
  5. class Animal(Organism):
  6.     def eat(self):
  7.         print("This animal is eating")
  8. class Dog(Animal):
  9.     def bark(self):
  10.         print("This dog is barking")
  11.  
  12.  
  13. dog = Dog()
  14. print(dog.alive)
  15. dog.eat()
  16. dog.bark()
  17.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement