Question: In PYTHON please (4) (25points) File reading, calculating, and exception error handling questions. Assume a file contains a series of integers in file numbers.txt. You

In PYTHON please In PYTHON please (4) (25points) File reading, calculating, and exception error handling

(4) (25points) File reading, calculating, and exception error handling questions. Assume a file contains a series of integers in file numbers.txt. You can find the file (numbers.txt) in canvas. First, copy the file into the same directory as this python program. Then, write a program that calculates the average of all the numbers stored in the file. Finally, your program needs to handle the exception with appropriate error messages. When everything goes well, the average of all the numbers = 4.75 Modify the program to handle the following exceptions with messages: (hint: modify your code one at a time to trigger one of the following exceptions and restore it before simulating another error. a) IOErroer: An error occurred while trying to read the file. [Errno 2] No such file or directory: 'numbers.txt' b) ValueError : Non-numeric data found in the file could not convert string to float: 'a \ ' c) Exception: An error occurred float division by zero

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!