Home / Expert Answers / Computer Science / number-analysis-program-adapted-from-4-save-the-file-as-ch7-ex1-py-design-a-program-that-load-pa556

(Solved): Number Analysis Program (adapted from #4) - Save the file as ch7_ex1.py Design a program that load ...



Number Analysis Program (adapted from #4) - Save the file as ch7_ex1.py Design a program that loads a text file containing a - Show the highest number in the list
- Show the total of the numbers in the list
- Show the number of lines in the list
- ShThe output should look EXACTLY like this for 7-1-numbers.txt:
\( [3581,3719,6766,490,3550,9807,6704,7524,628,827,4250,9878 \)

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: - Include a try block that will handle IOError exceptions. Use the file path argument, open the text file for reading. - Read all the lines from the open file. Close the file. Strip the trailing ' \( \backslash n \) ' 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. - 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 - Show the highest number in the list - Show the total of the numbers in the list - Show the number of lines in the list - Show the average of the numbers in the list Test the program using the following text file (download from BlackBoard assignment page): 7-1-numbers.txt The output should look EXACTLY like this for 7-1-numbers.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 \), \( 8687,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: \( \quad 16 \) High: 9878 Total: 478,292 \( \begin{array}{ll}\text { Lines: } & 100 \\ \text { Avg: } & 4,782.92\end{array} \)


We have an Answer from Expert

View Expert Answer

Expert Answer


read_file () functi
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe