Deviation - green tick but no print


I followed the instructions step by step. I got the green tick but it doesn't print the result.

#computing standard deviation
def grades_std_deviation(variance):
    return variance**0.5
    variance = grade_variance(grades)
    print grades_std_deviation(variance)


Your code should be indented in this manner for proper control flow,

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


Ok... but I don't understand why. Could you please explain?


Control flow is the order in which individual statements, instructions or functions are executed or evaluated. If your code is badly indented then it will be badly evaluated resulting in an error. :slight_smile:


Hi @aviss ,

Specifically, the problem that @bandit corrected was that you had these two statements indented, which made them part of the grades_std_deviation function ...

    variance = grade_variance(grades)
    print grades_std_deviation(variance)

That is one of the reasons that they did not execute. To get statements that are part of a function to execute, the function must be called. However, in this case, even calling the function would not have caused those statements to execute, because they were positioned after a return statement, which causes function execution to terminate, and then passes control back to where the function was called.


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