Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

An animal has attributes such as species and age. A mammal is a kind of animal that has additional attributes such as the colour of

An animal has attributes such as species and age. A mammal is a kind of animal that has additional attributes such as the colour of its fur (all mammals have fur/hair).
We have started some code for an Animal class and a Mammal subclass, and now we want to implement initializers. Which code is the most appropriate?
Group of answer choices
class Animal:
"""DOCSTRING OMITTED"""
def __init__(self, species: str, age: int)-> None:
"""Initialize this Animal.
Precondition: age >=0
"""
self.species = species
self.age = age
class Mammal(Animal):
"""DOCSTRING OMITTED"""
def __init__(self, species: str, age: int, fur_colour: str)-> None:
"""Initialize this Mammal.
Precondition: age >=0
"""
Animal.__init__(self, species, age)
self.fur_colour = fur_colour
class Animal:
"""DOCSTRING OMITTED"""
def __init__(self, species: str, age: int)-> None:
"""Initialize this Animal.
Precondition: age >=0
"""
self.species = species
self.age = age
class Mammal(Animal):
"""DOCSTRING OMITTED"""
def __init__(self, species: str, age: int, fur_colour: str)-> None:
"""Initialize this Mammal.
Precondition: age >=0
"""
Animal.__init__(self)
self.fur_colour = fur_colour
class Animal:
"""DOCSTRING OMITTED"""
def __init__(self, species: str, age: int)-> None:
"""Initialize this Animal.
Precondition: age >=0
"""
self.species = species
self.age = age
class Mammal(Animal):
"""DOCSTRING OMITTED"""
def __init__(self, species: str, age: int, fur_colour: str)-> None:
"""Initialize this Mammal.
Precondition: age >=0
"""
self.species = species
self.age = age
self.fur_colour = fur_colour
class Animal:
"""DOCSTRING OMITTED"""
def __init__(self, species: str, age: int)-> None:
"""Initialize this Animal.
Precondition: age >=0
"""
self.species = species
self.age = age
class Mammal(Animal):
"""DOCSTRING OMITTED"""
def __init__(self, species: str, age: int, fur_colour: str)-> None:
"""Initialize this Mammal.
Precondition: age >=0
"""
Animal.__init__(self, species, age)
self.species = species
self.age = age
self.fur_colour = fur_colour

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

1285427106, 978-1285427102

More Books

Students also viewed these Databases questions