Question: Python problem. Please help Find five errors in the following Python program and give the reasons why they are errors assuming the programmer is defining

Python problem. Please help

Find five errors in the following Python program and give the reasons why they are errors assuming the programmer is defining a class called Moon and creating an object called lunar of type Moon then calling its methods. (Line numbers are not part of the program. They are given for easy identification.)

1. class Moon

2. earthWeight

3. moonWeight = earthWeight/6

4. def setMoonWeight(ew):

5. if ew != 0:

6. earthWeight = ew

7. self.moonWeight = ew/6

8. def getMoonWeight(self):

9. return self.moonWeight

10. def main():

11. earth = float(input("What is the weight of earth: ")

12. Moon lunar

13. setMoonWeight(earth)

14. print("The weight of earth lunar is ", getMoonWeight() )

15. main()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!