Hi everybody, I can’t get past this as I get the following error:
Traceback (most recent call last):
File “python”, line 37, in
File “python”, line 28, in grades_std_deviation
TypeError: unsupported operand type(s) for ** or pow(): ‘list’ and ‘float’
However, I don’t see my code any different from that of everyone else… I have a feeling that the std function might have a problem because it seems to always return the same value no matter the input (at least according to the codacademy console!!). My code:
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) variance = 0 for score in scores: variance += ((average - score) ** 2) return variance / float(len(scores)) def grades_std_deviation(variance): return variance ** 0.5 variance = grades_variance(grades) print grades_std_deviation(variance) print print_grades(grades) print grades_sum(grades) print grades_average(grades) print grades_variance(grades) print grades_std_deviation(grades)
Could you help me figure out what’s wrong so that I can go forward to the next please?