5/19


#1

I'm pretty lost on this one. Heres what i got

grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5]

def grades_sum(scores):
total = 0
for item in scores:
total = total + item
return total
print grades_sum(grades)

def grades_average(grades):
total = 0
for i in grades:
total = total + i
new_total = total / float(len(grades))
return total
print grades_average(grades)


#2

Hmm... your function grades_average returns total (sum of grades) instead of new_total. Also try to call a function grades_sum inside grades_average to avoid calculating sum of grades again (get rid of for loop).
But if you want to go this way, you should calculate average (new_total) after the for loop.


#3

I did use a for loop and got this:

def grades_average(grades):
    total = 0
    for numbers in grades:
        total += 1
        new_total = float(grades_sum(grades)) / total
    return new_total

print "The average of all grades is", str(grades_average(grades))