Python multilevel inheritance

Your video will begin in 10
75 Views
Published
python multilevel inheritance tutorial example explained

#python #multilevel #inheritance

# multi-level inheritance = when a derived (child) class inherits another derived (child) class

class Organism:

alive = True

class Animal(Organism):

def eat(self):
print("This animal is eating")

class Dog(Animal):

def bark(self):
print("This dog is barking")


dog = Dog()
print(dog.alive) # inherited from the Organism class
dog.eat() # inherited from the Animal class
dog.bark() # defined in Dog class

Bro Code merch store
Category
Bro Code
Tags
Python, Python multilevel, Python multilevel inheritance
Be the first to comment