Variance


#1

Hi, All,
Stuck at 'Variance" for a whole day.Error message:-
File "python", line 24
** int grades_variace(grades)**
** ^**
SyntaxError: invalid syntax.
But cant find any.Please help.My code is as below

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

    def grades_sum(scores):
    sum=0
    for i in scores:
        sum +=i 
    print sum
    return sum

    def grades_average(grades):
    total= grades_sum(grades)
    leng=len(grades)
    if total%leng==0:
        average=total/leng
    else: average=total/float(leng)
    print average
    return average 
    def grades_variace(scores):
    average=grades_average(scores)
    variance=0
    for i in scores:
        variance +=(average-i)**2
    return variance/float(len(scores)

    print grades_variace(grades)

7. Variance
#2

Hint: If a statement is to be inside a method, it has to be indented four spaces to the right.

Take this example:

def grades_sum(scores):
sum=0
for i in scores:
    sum +=i 
print sum
return sum

you probably expect all the statements (except the first line obviously) to be inside the method grades_sum.

Do you now know how to fix the issue?


Variance Calculation Error