Big Data EX 4
Big Data EX 4
ALGORITHM:
CODE:
class Animal:
def speak(self):
print("The animal makes a sound.")
class Dog(Animal):
def speak(self):
print("The dog barks.")
class Cat(Animal):
def speak(self):
print("The cat meows.")
def make_animal_speak(animal):
animal.speak()
if _name_ == "_main_":
dog = Dog()
cat = Cat()
print("Dog's action:")
dog.speak()
print("Cat's action:")
cat.speak()
print("Polymorphism demonstration:")
make_animal_speak(dog)
make_animal_speak(cat)
OUTPUT:
RESULT:
Thus the program to perform inheritance and polymorphism is implemented and the
output is verified successfully.