QUESTION

Text
Image


Implement the following function in the PyDev module functions. py and test it from a PyDev module named to6.py: Work with the numbers.txt file in this question. def number_stats (fh): Returns statistics on the numbers in a file. Assumes file is not empty. Use: smallest, largest, total, average = number stats (fh) Parameters: fh - file to search (file handle - already open for reading) Returns: smallest - smallest number (int) largest - largest number (int) total - sum of all the numbers in the file (int) average - average of all the numbers (float) " 1 . def number_stats(fh): "II" Returns statistics on the numbers in a file. Assumes file is not empty. Use: smallest, largest, total, average = number_stats $(\mathrm{fh})$ Parameters: fh - file to search (file handle - already open for reading) Returns: smallest - smallest number (int) largest - largest number (int) total - sum of all the numbers in the file (int) average - average of all the numbers (float) " "। " Sample testing: Smallest: 1 Largest: 13 Total: 113.00 Average: 7.06 Smallest: 1 Largest: 13 Total: 113.00 Average: 7.06

numbers.txt file:


$\begin{array}{l}1 \\ 2 \\ 6 \\ 7 \\ 3 \\ 4 \\ 5 \\ 6 \\ 7 \\ 8 \\ 9 \\ 9 \\ 10 \\ 11 \\ 12 \\ 13\end{array}$

please do not use open, or close or readlines.

Please it should have only one return statement

Public Answer

Q3MBTS The First Answerer