Is the Bat a Mammal or a Bird?
You have been given a task to create a Python program that will demonstrate the concept of multiple inheritance and class hierarchy. The program should include four classes:
Animal
: This is a general class that represents any animal. It has one method:is_animal()
, which printsThis is an animal
.
Mammal
: This is a specific class that represents mammals and inherits from theAnimal
class. It has an additional method:is_mammal()
, which printsThis is a mammal
.
Bird
: This class represents birds and also inherits from theAnimal
class. It has an additional method:is_bird()
, which printsThis is a bird
.
Bat
: This class represents a bat, a unique creature that is both a mammal and a bird due to its ability to fly. This class inherits from bothMammal
andBird
classes.
Input | Output |
bat = Bat(); bat.is_animal(); bat.is_mammal(); bat.is_bird(); | This is an animal
This is a mammal
This is a bird |
Constraints
Time limit: 1 seconds
Memory limit: 512 MB
Output limit: 1 MB