Polymorphism
What is Polymorphism?
Basic Example
class Bird:
def make_sound(self):
print("Chirp")
class Dog:
def make_sound(self):
print("Woof")
def animal_sound(animal):
animal.make_sound()
bird = Bird()
dog = Dog()
animal_sound(bird) # Output: Chirp
animal_sound(dog) # Output: WoofReal World Use Cases
Key Points
Last updated