Implement function avg() that takes as input a list that contains lists of numbe
ID: 3754751 • Letter: I
Question
Implement function avg() that takes as input a list that contains lists of numbers. Each number list represents the grades a particular student received for a course. For example, here is an input list for a class of four students: (195, 92, 86, 871, (66, 54], [89, 72, 100], [33, 0, 01 The function avg should print, one per line, every student's average grade. You may assume that every list of grades is nonempty, but you may not assume that every student has the same number of grades. >>s avg(t(95, 92, 86, 87], (66, 541, [89, 72, 100), (33, 0, 0]1) 90.0 60.0 87.0 11.0Explanation / Answer
# [your_name]
# this program gives the average of grades of every student
def avg(a):
for y in a:
sum = 0
for x in y:
sum = sum + x
print(sum/len(y))
avg([[10, 20, 30],[20,50],[5,15,20]])
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.