Question: (python)Write a function that takes in a list of lists of equal length and then produces their average list, i.e. this is a list where

(python)Write a function that takes in a list of lists of equal length and then produces their average list, i.e. this is a list where the entry in index [i] is the average of all the given entries in index [i].

def avgList(myList): # YOUR CODE HERE raise NotImplementedError()

assert sum([abs(avgList([[1, 1, 1],[2, 2, 2]])[i]- [1.5, 1.5, 1.5][i]) for i in range(3)]) <= .1 assert sum([abs(avgList([[1, 2, 3],[3, 2, 1]])[i]- [2.0, 2.0, 2.0][i]) for i in range(3)]) <= .1 assert sum([abs(avgList([[1, 2, 3],[3, 2, 1],[1, 3, 2]])[i]- [1.66, 2.33, 2.0][i]) for i in range(3)]) <= .2 assert sum([abs(avgList([[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]])[i]- [2.0, 2.0, 2.0][i]) for i in range(3)]) <= .2

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!