Question: class Animal: def init _ ( self , name, habitat ) : if habitat ! = type ( self ) . habitat: raise Exception (
class Animal:
def
init
self name, habitat:
if habitat typeselfhabitat:
raise Exception:s is an invalid habitat for animal :sformathabitat name
self.name name
class HorseAnimal:
habitat 'land'
def movesself:
printInThe horse named :s gallops on :formatselfname, self.habitat
class WhaleAnimal:
habitat 'ocean'
def movesself:
printInThe whale named :s swims along :formatselfname, self.habitat
class TigerAnimal:
habitat 'mountain'
def movesself:
printInThe tiger named :s roars aloft in :formatselfname, self.habitat
class EagleAnimal:
habitat air'
def movesself:
printInThe eagle named :s soars aloft in :formatselfname, self.habitat
class Snakel:
def init.
self name, habitat:
if habitat 'ground':
raise Exception:s is an invalid habitat for animal :sformathabitat name
self.name name
def movesself:
printInThe snake named :s slithers along' formatselfname What is true about the code in this question after the above definitions are executed and the following global code is executed? Check all that apply.
Ed Horse Mr Ed 'land
Moby Whale Moby Dick', 'ocean'
Monty Snake Python 'ground'
Angie Eagle Angeline 'air
for m in Ed Moby, Monty, Angie:
mmoves
the code contains examples of inheritance
the code contains an example of Python duck typing
the code contains examples of polymorphic behavior
each of the classes has a constructor, either inherited or as part of its definition
all classes are either Animal or subclasses of Animal
None of the listed answers is correct
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
