Oops, try again! The grades variable should contain a list of grades


#1

Hello all,

Wondered if anyone has seen this issue before.

I'm stuck in Exam Statistics Review - Section 9. All my functions look good and print properly however, I keep getting this error message whenever I Save & Submit code.

I've printed the grades list before and after printing the function values. Please help.

The output of my functions and code are as follows:
[100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5] << - grades =
100
100
90
40
80
100
85
70
90
65
90
85
50.5
1045.5 << - Sum of the grades
80.4230769231 << - Average
334.071005917 << - Variance
18.2776094147 << - Standard Deviation
[100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5] << -- grades variable to make sure it wasn't damaged
None

My code follows:
grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5]

def print_grades(scores):
for grade in scores:
print grade
return

def grades_sum(scores):
total = 0
for grade in scores:
total += grade
return total

def grades_average(scores):
sum_of_grades = grades_sum(scores)
average = sum_of_grades / float(len(scores))
return average

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

def grades_std_deviation(variance):
return (variance ** 0.5)

print grades
print_grades(grades)
print grades_sum(grades)
print grades_average(grades)
print grades_variance(grades)
print grades_std_deviation(variance)
print grades


#2

Well, I haven't been able to quite finish this, but it looks that you are missing a line in your code that calculates the variance for you:

def grades_std_deviation(variance):
    return (variance ** 0.5)

variance = grades_variance(grades)

print grades
print_grades(grades)
print grades_sum(grades)
print grades_average(grades)
print grades_variance(grades)
print grades_std_deviation(variance)
print grades

#3

Hi buddy,

I totally missed that! Thanks a lot.

Chas