Inheritence contd–Overriding
- Method overriding means the child class changes the behavior of a method from the parent class
class Animal:
def make_sound(self):
print("........")
class Dog(Animal):
def make_sound(self):
print("bark")
class Cat(Animal):
def make_sound(self):
print("meow")
animal = Animal()
cat = Cat()
dog = Dog()
print("Animal")
animal.make_sound()
print("Cat")
cat.make_sound()
print("Dog")
dog.make_sound()
-
Super(): super means call the parent version of this method
-
Multi Level Inheritence:
Animal
Dog
Puppy
-
Multiple inheritence: Where one class inherits from more than one parent class
-
Refer Here for the notebook
