Question: Abstract Pythons Unlike Java, Python does not have an idea of an interface, but it does have some idea of abstract methods, abstract classes and
Abstract Pythons
Unlike Java, Python does not have an idea of an interface, but it does have some idea of abstract methods, abstract classes and multiple inheritance.
In this exercise, we're going to set up an abstract class Animal, which has an abstract noiseself method that when implemented returns a string representing the noise the animal makes.
Then we will create animals that all inherit from Animal, and thus have to implement their own noiseself:
Cats "meow"
Dogs "woof" and
Frogs "ribbit".
ie the three classes are Cat, Dog and Frog, and their noiseself method should return "meow", "woof" and "ribbit" respectively
Note that the point here is to familiarise ourselves with the syntax and setup of abstract classes in Python. You can make this work in simpler ways without the abstract part, but it's handy to know it exists.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
