Answered step by step
Verified Expert Solution
Question
1 Approved Answer
For the following code and using the help() function on the Moon class, what method(s) are inherited from Planet? a.) _init__(self, name, num_Moons) show_moons(self) b.)
For the following code and using the help() function on the Moon class, what method(s) are inherited from Planet? a.) _init__(self, name, num_Moons) show_moons(self) b.) show_name(self) show_moons(self) c.) show_moons(self) d.) show_name(self) You have created the following base class of planets and a subclass of it of planets with rings: class Planet: def _init_(self, name): self.name = name self.orbits_a_star = True self.mass_enough_to_form_a_sphere = True self.cleared_neighborhood_around_orbit = True class Planets_With_Rings(Planet): def _init_(self, name, num_Rings): super()._init_(name) self.rings = num_Rings What code segment would properly create an instance of this subclass using variable P6rings, name it Saturn, assign its number of large rings, and print out its status? a.) P6rings = Planet('Saturn', 7) print(P6rings. name, 'has', P6rings.rings, 'rings') b.) P6rings = Planets_With_Rings() print(P6rings.name, 'has', P6rings.rings, 'rings') c.) P6rings = Planets_With_Rings('Saturn', 7) print(P6rings.name, 'has', P6rings.rings, 'rings') d.) P6rings = Planets_With_Rings ('Saturn', 7) print(P6rings, 'has', P6rings,'rings') For the subclass Contractor of the base class Person example provided in the tutorial, what if we need to keep track of the project for each contractor? What code segment could be used to properly initialize, and add methods to set and get this value? a.) class Contractor(Person): def _init_(self, fname, lname, title, wage, contractorid): super()._init_(fname, Iname, title) self. contractorid = contractorid self.hourlywage = wage self.project = project def get_project(self): return self.project def set_project(self, project): self.project = project b.) class Contractor(Person): def _init__(self, fname, lname, title, wage, contractorid, project): super()._init_(fname, lname, title) self.contractorid = contractorid self.hourlywage = wage self.project = project def get_project(self): return project def set_project(self, project): self.project = project c.) d.) class Contractor(Person): def _init__(self, fname, lname, title, wage, contractorid, project): self. contractorid = contractorid self.hourlywage = wage self.project = project def get_project(self): return self.project def set_project(self, project): self.project = project
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started