Question: 1. Number Analysis Program (adapted from #4) Save the file as ch7_ex1.py Design a program that loads a text file containing a series of numbers,

1. Number Analysis Program (adapted from #4) Save the file as ch7_ex1.py Design a program that loads a text file containing a series of numbers, then presents information about the numbers in the list. Your program must: Declare a variable named num_list and initialize it as an empty list Include a function named read_file that accepts a file path and returns a list of numbers. This function will: o Include a try block that will handle IOError exceptions. o Use the file path argument, open the text file for reading. o Read all the lines from the open file. o Close the file. o Strip the trailing from each line and convert the string to an integer. Hint: All the list elements must be an int for the math functions to work. o Return the list of integers read from the file. Populate the num_list variable by calling the read_file function and passing the file name as an argument. Print the entire list Show the lowest number in the list IS 2053 Show the Show the highest number in the list total of the numbers in the list Show the number of lines in the list Show t he average of the numbers in the list Test the program using the following text1assignment page): 7 numbers.txt of 4 IS 2053 file (download from BlackBoard CH07 Programming Exercises Page 2 John NewsomIS 2053 The output should look EXACTLY like this for 71numbers.txt : [3581, 3719, 6766, 490, 3550, 9807, 6704, 7524, 628, 827, 4250, 9878, 4284, 5982, 1580, 1294, 8029, 6285, 8782, 2423, 6047, 674, 3093, 6479, 2168, 5823, 6277, 16, 4141, 4061 , 6085, 7133, 1877, 9375, 1437, 2825, 4401, 1023, 6726, 5590, 3004, 6544, 1781, 8283, 1685, 9410, 8793, 2501, 4601, 3103, 2851, 3154, 4410, 8612, 7966, 1701, 7600, 5264, 7193, 3237, 4518, 9061, 2092, 9530, 3277, 7873, 6213, 6546, 7208, 6855, 691, 2038, 868 7, 2259, 3859, 3673, 3034, 8835, 6664, 3332, 2277, 2269, 6708, 5224, 5393, 5242, 2312, 2626, 8189, 2647, 6209, 170, 6133, 3991, 2882, 1291, 8604, 216, 7130, 9207] Low: 16 High: 9878 Total: 478,292 Lines: 100 Avg: 4,782.92 of 4

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