# 5. Computing the Average (Exam Statistics)

#1

This is just the weirdest error. I don’t understand what has gone wrong It says:
grades should contain [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5].

By the looks of the console my code has worked just fine, what is displayed on the console is this:

This is your list: [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5]
100 + 100 + 90 + 40 + 80 + 100 + 85 + 70 + 90 + 65 + 90 + 85 + 50.5 = 1045.5
80.4230769231

This is my code:

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

count = 0
print "This is your list:", scores
for x in range(len(scores)):
count = count + scores[x]
scores[x] = str(scores[x])
print " + ".join(scores), "=",
print count
return count

return avg

print yes
``````

#2

You are overthinking this. Try following this template:

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

def FUNCTION_ONE(PARAMETER):
return sum(PARAMETER)

def FUNCTION_TWO(PARAMETER):
return FUNCTION_ONE(PARAMETER) / float(len(PARAMETER))

print FUNCTION_TWO(VARIABLE)
``````

Make sure not to just follow the template and move on. I want to make sure that you understand how and why this works. If you have any questions, just ask.

#3

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