Review help please


#1



I have done what the exercise requests but now for some reason it appear the standard deviation function isn't working. Please help.

review


Traceback (most recent call last):
File "python", line 33, in
File "python", line 26, in grades_std_deviation
TypeError: unsupported operand type(s) for ** or pow(): 'list' and 'float'


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

def print_grades(grades):
    for grade in grades:
        print grade

def grades_sum(grades):
    total = 0
    for grade in grades: 
        total += grade
    return total
    
def grades_average(grades):
    sum_of_grades = grades_sum(grades)
    average = sum_of_grades / float(len(grades))
    return average

def grades_variance(scores):
    average = grades_average(scores)
    varience = 0
    for score in scores:
        varience += ((average - score) ** 2)
    return varience / len(scores)

def grades_std_deviation(varience):
    return varience ** 0.5


print "X got", print_grades(grades)
print "Grade sum is", grades_sum(grades)
print "Grade average is", grades_average(grades)
print "Grade varience is", grades_varience(grades)
print "Standard deviation of all grades is", grades_std_deviation(grades).


#2

Check the spelling against your function name.

That function is only returning a square root. It should be passed the result of grades_variance().


#3

I really don't know how I didn't see that, thank you


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.