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
Post a Comment
Write something to CodeWithAbdur!