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
Get step-by-step solutions from verified subject matter experts
