Question: PYTHON!HELP!Grade Average with Exceptions the programmer needs to catch all possible exceptions within the program, give an intelligent error message to the user, and allow
PYTHON!HELP!Grade Average with Exceptions
the programmer needs to catch all possible exceptions within the program, give an intelligent error message to the user, and allow the user to reenter the data so the program may continue. In the Grade Average program, there are two possible exceptions that can be caused by the user; the user can type in something that is not a number, e.g. 'fred', causing a ValueError, or the user can enter a negative number without entering any numbers to average causing a ZeroDivisionError. You must modify the program to use a loop any place the user enters a number to keep requesting them to enter a number until they enter a number.
You will also add the following function to your program: calculateAverage(sum, count) where sum is the sum to be averaged and count is the count of the numbers in sum. It will return the average which is simply sum/count or it will raise a ValueError if count = 0. In the main logic of the program, you will call calculateAverage to get the average but must catch the ValueError if it is raised.
You will see that by making the program robust, you will more than double the amount of code in the assignment.
is there any possible to just conclude every request in to one def? or we need more?
Thanks!

Python 3.6.4 Shell File Edit Shell Debug Options Window Help Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel) on win32 Type "copyright", "credits" or "license )" for more information. RESTART: P:/Cmpsc131/Programming Assignment Solutions/PA13AverageofNumbersWithExceptions.py Enter a positive number to total or a negative number to calculate average: 10 Enter a positive number to total or a negative number to calculate average: 20 Enter a positive number to total or a negative number to calculate average: up What you entered was not a valid number. Try again. Enter a positive number to total or a negative number to calculate average: 30 Enter a positive number to total or a negative number to calculate average: 40 Enter a positive number to total or a negative number to calculate average: -10 The sum of the numbers is: 100.0 The average of the numbers is: 25.0 RESTART: P:/Cmpsc131/Programming Assignment Solutions/PA13AverageofNumbersWithExceptions.py Enter a positive number to total or a negative number to calculate average: -2 You did not enter any numbers to average
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
