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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started