Question: Write a python program that reads a series of integers (one integer on each line) from a file stored on hard disk and calculates the
Write a python program that reads a series of integers (one integer on each line) from a file stored on hard disk and calculates the average of all the numbers in the file. The name of the file on the hard disk is numbers.txt The program handles the following separate individual exceptions: ? FileNotFoundError (IOError) exceptions that are raised when file is opened and data is read from it. ? ValueError exceptions that are raised when items that are read from the file and converted to a number. In case of any error, there should be a prompt asking if the user would like to correct the error and then execute. The user can correct the error and type Y to continue execution or type any other letter to quit execution. In this task you will need to include three separate exception handlers - FileNotFoundError (IOError), ValueError and another to capture any other error. Hint: try: ......... exceptFileNotFoundError:.............exceptValueError:.............except:.........
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
