Platypus

Report a typo

In the code template below you can see the class Animal with the __init__method. This class is the root of a class hierarchy.

Your task is to add classes Mammal, Reptile and Platypus to this hierarchy.

  • Class Mammal should inherit from the class Animal. You should also override the __init__. First, you should print the message Created a Mammal and then call the __init__ of the parent class using the super() function.
  • Class Reptile should inherit from the class Animal. You should also override the __init__. First, you should print the message Created a Reptile and then call the __init__ of the parent class using the super() function.
  • Class Platypus should inherit from classes Mammal and Reptile in this order. You should also override the __init__ method in a similar way: print the message Created a Platypus and then call the __init__ of the parent class.
Write a program in Python 3
class Animal:
def __init__(self, name):
self.name = name
print("Created an Animal")

# create the rest of the classes here
___

Create a free account to access the full topic