subject

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.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 01:20
What is the full meaning of rfid in computer
Answers: 2
question
Computers and Technology, 22.06.2019 20:00
What is the worst-case complexity of the maxrepeats function? assume that the longest string in the names array is at most 25 characters wide (i.e., string comparison can be treated as o( class namecounter { private: int* counts; int nc; string* names; int nn; public: namecounter (int ncounts, int nnames); int maxrepeats() const; }; int namecounter: : maxrepeats () { int maxcount = 0; for (int i = 0; i < nc; ++i) { int count = 1; for (int j = i+1; j < nc; ++j) { if (names[i] == names[j]) ++count; } maxcount = max(count, maxcount); } return maxcount; }
Answers: 3
question
Computers and Technology, 23.06.2019 00:30
Write the html code to make a link out of the text “all about puppies”. it should link to a pdf called “puppies.pdf” inside the “documents” folder. the pdf should open in a new window.
Answers: 2
question
Computers and Technology, 23.06.2019 19:30
Anul 2017 tocmai s-a încheiat, suntem trişti deoarece era număr prim, însă avem şi o veste bună, anul 2018 este produs de două numere prime, 2 şi 1009. dorel, un adevărat colecţionar de numere prime, şi-a pus întrebarea: “câte numere dintr-un interval [a,b] se pot scrie ca produs de două numere prime? “.
Answers: 3
You know the right answer?
PYTHON!HELP!Grade Average with Exceptions

the programmer needs to catch all possible ex...
Questions
question
Mathematics, 16.01.2022 03:00
question
Mathematics, 16.01.2022 03:00
question
Mathematics, 16.01.2022 03:00
question
World Languages, 16.01.2022 03:10
Questions on the website: 13722363