Modify your program to use at least one method to perform the same task. You will also need to add exception handling to your program and to your method. MY CODE IS BELOW create a method to save the numbers the user entered into a list Your method must perform the following The method must take in at least one value as a parameter. The method must return a value You must use Exception handling in your method HERE is my code numList = [] while(True): variable = input("Enter a number or Enter done to quit: ") if(variable=='done'): break numList.append(int(variable)) # display the information print("The total amount of numbers entered : ",len(numList)) print("The total of numbers : ",sum(numList)) print("The average of all numbers : ",sum(numList)/len(numList)) print("The largest number is: ",max(numList))
Modify your program to use at least one method to perform the same task. You will also need to add exception handling to your program and to your method.
MY CODE IS BELOW
- create a method to save the numbers the user entered into a list
Your method must perform the following
- The method must take in at least one value as a parameter.
- The method must return a value
- You must use Exception handling in your method
HERE is my code
numList = []
while(True):
variable = input("Enter a number or Enter done to quit: ")
if(variable=='done'):
break
numList.append(int(variable))
# display the information
print("The total amount of numbers entered : ",len(numList))
print("The total of numbers : ",sum(numList))
print("The average of all numbers : ",sum(numList)/len(numList))
print("The largest number is: ",max(numList))
I have implemented your code according to your requirements , Kindly check that out , I have written comments for better understanding.
Step by step
Solved in 3 steps with 1 images