# Unit 9: exam statistics

#1

Hi!
I stuck at UNIT 9: EXAM STATISTICS:
This is my code

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

for score in scores:
print score

total = 0
for score in scores:
total += score

return average

variance = 0
for score in scores:
variance += (average - score) ** 2
return variance / len(scores)

return variance ** 0.5

and this is output

``````100
100
90
40
80
100
85
70
90
65
90
85
50.5
1045.5
Traceback (most recent call last):
File "python", line 30, in <module>
File "python", line 24, in grades_variance
File "python", line 19, in grades_average
TypeError: 'float' object is not callable``````

can't get what's wrong ((( help me, please

#2

Issue with indentation basically. See below:

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

#3

do you really mean i should call function inside it's own definition?

#4

hmm, i did that, but get the same output

#5

You know, python uses indentation to specify where what does what. Please post full code after considering my initial suggestion.

Thank you!

#6

code:

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

for score in scores:
print score

total = 0
for score in scores:
total += score

return average

variance = 0
for score in scores:
variance += (average - score) ** 2
return variance / len(scores)

return variance ** 0.5

output:

``````100
100
90
40
80
100
85
70
90
65
90
85
50.5
1045.5
Traceback (most recent call last):
File "python", line 30, in <module>
File "python", line 24, in grades_variance
File "python", line 19, in grades_average
TypeError: 'float' object is not callable``````

#7

When I saw that the error was from previous lines, I did a revisit and you had some mix-up. The standard deviation function created has dependency on about all previous.

Scan through and see my edits.

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

total = 0

return average

variance = 0
for score in scores:
variance += (average - score) ** 2
result = variance/len(scores)
return result

return variance ** 0.5

#8

All works fine now!
Thank you!

#9

You're welcome.

Have fun coding!

#10

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