Question: Problem II: Reading Numbers This problem assumes you have completed Program I, Writing Random Numbers. Coal: Write a program that reads the numbers from a

Problem II: Reading Numbers
This problem assumes you have completed Program I, Writing Random Numbers.
Coal: Write a program that reads the numbers from a file and then displays the number of random numbers read from the file, the total of the numbers, and the average of the numbers (rounded to two decimal places).
Design: Optionally, design your program logic using pseudocode in the IPO diagram. You do not have to submit the diagram to the instructor.
Modularity: Your program should use functions, as the best practices suggest. At least one function is expected.
Exception Handling: The program should use Iry and Except clauses to handle IOEzzox, ValueExyor, ZeroDivisionEisor, and unspecified error exceptions. Be sure to test your programs for invalid cases. For example, try ruming the program to read the file when it doesn't exist, is empty, or manually put bad data in the file and see what happens.
Output:
No exceptions:
Reading the file done.
Read from the file: 80 numbers.
Total of the numbers: 5600
Average of the numbers: 70.00
IOExror exception (fille doesn't exist)
Reading the file... this filename doesn't exist. Program terminated.
ValueErioz exception (bad data in the file):
Reading the Eih. incoryect data type. Program terminated.
ZezoDivisionExror exception (empty file):
Reading the file. done.
Read from the file: 0 numbers.
Total of the numbers: 0
Average of the numbers: can't be calculated.
Usspecified exception:
Reading the file other error occurred. Program terminated.
-2-
Programming Style Requirewents
The file must use the _ main__variable to determine whether the file is being imported as a module or is being execured as a standalone program
Your program must use functions, as the best practices guggest (at least one function is expected)
Each function must begin widh a shoft comment explaining what the function does
Begin your program with a comment that includes your name and program status (either "Complete" or describe any incomplete or non-functioning par of your program)
Use meaningful verb names for functions such as di splay_ eakes
Use meaningful variable names such as total_ vaxes or num_ cookics
Use named constants for all number values that will not be changed in the program
Use F - Strings
Problem II: Reading Numbers This problem assumes

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 Programming Questions!