Question: Please use Python to solve this problem HW06 Attached Files: numbers.txt (24 B) Due: Wednesday, October 31st, 11:59 PM Late submissions not accepted. Goals: Process
HW06 Attached Files: numbers.txt (24 B) Due: Wednesday, October 31st, 11:59 PM Late submissions not accepted. Goals: Process a text file. Introduce exception handling. . Average of Numbers Assume that a file containing a series of integers is named numbers.txt and exists on thecomputer's disk. Write a program that calculates the average of all the numbers stored in the file. It should handle any IOError exceptions that are raised when the file is opened and data is read from it. It should handle any ValueError exceptions that are raised when the items that are readfrom the file are converted to a number . e A20-Point Sample Run: RESTART: C:/Users/Hank Stalica/Desktop/hwo6.py Stalica/Desktop/hw06.py C:/Users/Hank.Stalica/Desktop/hw06.py File IO Error. ssaa RESTART: C:/Users/Hank Failed to convert input to an integer. -a--RE--eae -RESTART : The average of the values in the file is: 34.857142857142854 In the above sample run, there are actually three sample runs in the first, I tried running the program without a numbers.txt file. in the second, the file had the word dog" in it. in the third run, the file was present and contained only integers on separate lines. Hints: Don't forget to close the file when you're done with it . There is no flow chart required 30 MacBook Pro
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
