Variance


#1



https://www.codecademy.com/en/courses/python-intermediate-en-7mgOa/2/2?curriculum_id=4f89dab3d788890003000096


def grades_std_deviation(variance):  
    variance=grades_variance(grades)
    return variance**0.5

print grades_std_deviation(variance)

this in a incorrect code, the error returned is "grades_std_deviation(6.1875) returned 18.2776094147 instead of the expected: 2.4874685928"

the right one should put "variance=grades_variance(grades)" outside of the defined function.

and why there is a difference when i put the " variance=grades_variance(grades)" outside of the defined function?
and what is the difference? i think no matter the "variance=grades_variance(grades)" is outside of function or not, the "print grades_std_deviation(variance)" and the function will call it anyway......

wish a explanation on that

thank you so much !!


#2

Hello @zoezhang1992foxmail,

Can you attach a link to the exercise you are doing? Thanks!


#3

i have attached the link, thank you so much !


#4

Hello there, @zoezhang1992foxmail,

The grades_std_deviation() function takes the variance of a list. You do not need to call grades_variance() on it, you simply have to return variance**0.5 and your code will be good to go.