Multi-level Inheritance in python

 


class Animals:
    animalCategory1 = "vertebrates"
    animalCategory2 = "invertibrates"

class Pets(Animals):
    petCategory1 = "cats"
    petCategory2 = "dogs"

class Dog(Pets):
    @staticmethod
    def bark():        
        print("The dog barks")

a = Animals()
b = Pets()
c = Dog()
print(a.animalCategory2)
print(b.animalCategory2)
print(c.animalCategory2)
print(b.petCategory2)
print(c.petCategory2)
a.animalCategory1 = "mammals"
print(a.animalCategory1)






Comments

Popular posts from this blog

Quotation marks to wrap an element in HTML

The Basic Structure of a Full-Stack Web App

Top 10 Telegram Hidden Features You Might Not Know About