Question: Ch 6 - P 9 . Exception Handling Modify the script Ch 6 / P 6 . py so it handles the following exceptions: It
ChP Exception Handling
Modify the script ChPpy so it handles the following exceptions:
It should handle any IOError exceptions that are raised when the file is opened and data read from it
It should handle any ValueError exceptions that are raised when the items that are read from the file are converted to a number.
create ChPpy
ChP Exception Handling
Modify the script ChPpy so it handles the following exceptions:
It should handle any IOError exceptions that are raised when the file is opened and
data read from it
It should handle any ValueError exceptions that are raised when the items that are read
from the file are converted to a number.
create ChPpy
submit two screenshots
GNU nano
PPy
rsrbtnpython
P
count
total
try:
infile opennumberstxtr
for line in infile:
#print line
num int line
count
total num
infile.close
print The Average is totalcount
except IOError:
print An I Error Occured"
except ValueError:
print Value Error"
except:
print Another type of Error"
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
