Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

All solutions are to be written using Python 3. Make sure you provide comments i

ID: 3669606 • Letter: A

Question

All solutions are to be written using Python 3. Make sure you provide comments including the file name, your name, and the date at the top of the file you submit. Also make sure to include appropriate docstrings for all functions. Occasionally, instructors w ill drop the lowest score from a series of scores on quizzes or homework assignments. Unfortunately for you, I'm not one of those instructors. On the other hand, I know instructors who would like to employ this policy but can't do the math. To encourage this sort of generosity among instructors, write a function called printAverages that expects a two-dimensional table of integers (implemented as a list of lists) as its only parameter, where each row of the table contains the quiz scores for a student. For each row of the table, your function should compute the average of all but the lowest score in the row and print that average. For example, given an table of quiz scores that looks like this: your printAverages function should print this: Average for rrow 0 is 100.0 Average for row 1 is 72.5 Average for row 2 is 7.5 You may assume that no quiz score is less than 0 or greater than 100. The values may be either integers or floating point numbers. You may also assume that every row contains the same number of scores. Note that only one lowest score in a row is dropped. Your function should not ask for keyboard input, and the only value it returns is None. Note that the table of scores could have any number of rows or columns so long as the number is greater than zero; the dimensions of the table will not necessarily be the same as in the example given on the previous page. The list of lists for the sample table would look like this:

Explanation / Answer

Answer in python 3:

def average(param):
""" Return Average, Receives as parameter (param) list simple """
if not isinstance(param, list):
param = [param]
average = 0
for j in param:
average = average + j
average = average / len(param)
return average

def printAverages(param):
""" Print Averages of the list receives as parameter """
if not isinstance(param, list):
param = [param]
count = 0
for i in param:
print('Average for row {0:0d} is {1:.1f}'.format(count, average(i)))
count = count + 1
  
  
printAverages([[100, 100, 0, 100, 100], [80, 75, 70, 65, 5], [0, 10, 10, 0, 10]])