Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python Program Error I cannot get this program to run correctly to output the message. class Bug: def _ _ init _ _ ( self

Python Program Error
I cannot get this program to run correctly to output the message.
class Bug:
def __init__(self, name, num_legs, num_wings):
self.name = name
self.num_legs = num_legs
self.num_wings = num_wings
def get_name(self):
return self.name
def set_name(self, name):
self.name = name
def get_num_legs(self):
return self.num_legs
def set_num_legs(self, num_legs):
self.num_legs = num_legs
def get_num_wings(self):
return self.num_wings
def set_num_wings(self, num_wings):
self.num_wings = num_wings
def __str__(self):
return f"This is a {self.name}. It has {self.num_legs} legs and {self.num_wings} wings."
class Spider(Bug):
def __init__(self):
super(Spider, self).__init__("Spider",8,8)
def __str__(self):
self.message = super(Spider, self).__str__()
self.message +="
The golden orb weaver has a mild venom that is not poisonous to humans."
return message
class Grasshopper(Bug):
def __init__(self):
super().__init__("Grasshopper",6,4)
self.fact = "Grasshoppers are common in the Everglades and play a vital role in the ecosystem."
def __str__(self):
self.message = super(Grasshopper, self).__str__()
self.message +="
Grasshoppers are common in the Everglades and play a vital role in the ecosystem."
return message
class Tester:
def __init__(self):
self.bug = Bug("Millipede",1000,0)
self.spider = Spider()
self.grasshopper = Grasshopper()
def print_info(self):
print(self.bug)
print(self.spider)
print(self.spider.message)
print(self.grasshopper)
print(self.grasshopper.message)
if __name__=="__main__":
tester = Tester()
tester.print_info()

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_2

Step: 3

blur-text-image_3

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

Select Healthcare Classification Systems And Databases

Authors: Katherine S. Rowell, Ann Cutrell

1st Edition

0615909760, 978-0615909769

More Books

Students also viewed these Databases questions