Question: IN PYTHON CODE Question #2 Write a function grade.stats that has two arguments: file_name that is a string that is the name of a text
IN PYTHON CODE

Question #2 Write a function grade.stats that has two arguments: file_name that is a string that is the name of a text file that contains the grades for the students in some course, and col that is a column number, with default value of 1 Each line of the file begins with the (first) name of a student, followed by a sequence of strings that are supposed to represent integers that lie between 0 and 100, inclusive. The elements of each line are separated by blank space The function should compute the average and median values of the valid numbers that appear in the specified column. Any string that appears in the specified column that does not represent an integer that lies between 0 and 100 inclusive, should be disregarded. If there are no valid numbers in the specified column, then the function should return no value. The statement return None will accomplish this. Note that you should not return the string "None", but rather the python None object If the specified column contains strings that represent integers between 0 and 100, then the function should return a tuple of length 3 that consists of in order: the average of the numbers in the column, rounded to 2 decimal places, the median of the numbers in the column, and the highest grade in the column. To test your code, you can use the file grades.txt that can be down loaded here: https://ms.mcmaster.ca/-matt/1mp3/homework/grades.txt Since the first column of this file does not contain any valid integer entries, then grade stats('grades.txt', 0) should return no value. On the other hand, grade.stats('grades.txt') should return the tuple (71.14, 78.0, 96) and grade-stats ('grades.txt', 5) should return the tuple (41.85 48, 60). Both columns 1 and 5 contain some non-valid entries. Note: To compute the average of a non-empty list of numbers, you can first sum the entries in the list (using the sum function) and then divide by the length of the list. The median of a sorted list of numbers of odd length is equal to the value of the middle entry of the list, while the median of a sorted list of numbers of even length is equal to the average of the two middle entries of the list
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
