Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python 3.7.2 Average of Numbers with Exception Handling Assume that a file containing a series of integers is named numbers.txt and exists on the computers

Python 3.7.2

Average of Numbers with Exception Handling

Assume that a file containing a series of integers is named numbers.txt and exists on the computers disk. Download this file which is attached. Write a program that calculates the average of all the numbers stored in the file. Make sure that the program should ask a file name to read. Modify the program that you wrote so it handles the following exceptions:

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 read from the file are converted to a number. Check and fix the file by removing non-numeric data. There are two non-numeric data cat and dog.

numbers.txt:

22 14 39 109 87 -99 333 78 65 76 292 282 239 cat 392 98 786 981 388 -987 -12 -45 383 381 1 23 40 dog

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MFDBS 89 2nd Symposium On Mathematical Fundamentals Of Database Systems Visegrad Hungary June 26 30 1989 Proceedings

Authors: Janos Demetrovics ,Bernhard Thalheim

1989th Edition

3540512519, 978-3540512516

More Books

Students also viewed these Databases questions

Question

What is competitive disadvantage? Why has it emerged as a factor?

Answered: 1 week ago

Question

Use Newton's methodto find*correcttC4decImalplaces.

Answered: 1 week ago

Question

Does it avoid use of underlining?

Answered: 1 week ago