•Create two classes named Mammals and MarineAnimals. Create another class named BlueWhale which inherits both the above classes. Now, create a function in each of these classes which prints "I am mammal", "I am a marine animal" and "I belong to both the categories: Mammals as well as Marine Animals" respectively. Now, create an object for each of the above class and try calling
1 - function of Mammals by the object of Mammal
2 - function of MarineAnimal by the object of MarineAnimal
3 - function of BlueWhale by the object of BlueWhale
4 - function of each of its parent by the object of BlueWhale
class Mammals:
def mammals():
print("I am mammal")
mammals()
class MarineAnimals:
def marineAnimals():
print("I am a marine animal")
marineAnimals()
class BlueWhale(Mammals, MarineAnimals):
def blueWhale():
print("I belong to both categories")
blueWhale()
Comments
Leave a comment