Problem in Standard Deviation exrecise

Hi!
I am learning Python and I am in Exam Statistic lesson, Standard Deviation
the link to the exercise - https://www.codecademy.com/courses/learn-python/lessons/exam-statistics/exercises/standard-deviation?action=resume_content_item

it is pretty straight forward exerecise, so I wrote down the following code and in the monitor a message says error:
Traceback (most recent call last): File “python”, line 30, in <module> File “python”, line 27, in grades_std_deviation TypeError: unsupported operand type(s) for ** or pow(): ‘list’ and ‘float’

my code:

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

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

def grades_sum(scores):
  total = 0
  for score in scores: 
    total += score
  return total
    
def grades_average(grades_input):
  sum_of_grades = grades_sum(grades_input)
  average = sum_of_grades / float(len(grades_input))
  return average

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

def grades_std_deviation(variance):
  return variance ** 0.5 #line 27

variance = grades_variance(grades)
print grades_std_deviation(grades)# line 30

when I checked the solution to this exercise, they did the same thing in def grades_std_deviation.
can you help me understand what I did wrong?
Thank you!

1 Like

you missed this bit of the instructions:

Finally print the result of calling grades_std_deviation(variance)

we calculate the variance of the grades, then using the variance, we calculate the standard deviation.

1 Like

Thank you for your help! I understand my mistake!!

1 Like