I am looking for help in how to 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. List for a class of four students.
([95,92,86,87],[66,54,],[89,72,100],[33,0,0]) the function avg should print one per line, every student's average grade.

Simply add the numbers in each list together with function sum() and divide by the number of items in the list.

grades = ([95,92,86,87],[66,54,],[89,72,100],[33,0,0])

    def avg(grades):
    for i in grades:
        avg = sum(i)/len(i)
        print("average = ",avg)

This should get you started.

Of course, NumPy (www.numpy.org) has exactly the routine you need.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.