# 9/9 Exam Statistics: Review not recognizing printed variables

#1

After printing the code for the lesson, everything is printed as it should be, but I get an error stating that:

“It looks like the sum of grades was not printed! Make sure you are printing it on its own line.”

Other than that error message, everything appears to be working correctly. I even calculated everything manually to make sure the printed information was correct and it was, so I don’t know why it doesn’t like the information that was printed. The output is as follows:

40
50.5
65
70
80
85
85
90
90
90
100
100
100

Standard deviation: 18.2776094147

``````

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

print

print

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

return variance ** 0.5

``````

#2

Print all of the values on individual lines. Codecademy checks for that result exact result.

``````print (grades_sum(grades))
``````

#3

Oh wow, never would have thought that it was failing because I made the result ‘too’ easily readable! I’ll have to remember that for the future, though I’m certainly still going to be formatting my printed lines because I like knowing at a glance exactly what I’m looking at rather than needing to refer to my code.

On a somewhat unrelated topic, which of the following methods is it best to format strings with?

``````"My %s text is %s back there!" % ("modified", "hiding")
"My {} text is {} back there!".format("modified", "hiding")
``````

Or is there another way I don’t know about that’s even better?

#4

I do it the good old fashioned way (probably not the best way) of concatenation.

``````"My "+text+" text is "+text2+" back there!"
``````

#5

Hmm, I hadn’t even really considered doing it that way… I wonder what the benefits and limitations of each of those three ways (and any others not yet mentioned) might be. I’m wondering because I’m trying to develop good habits now while I’m learning the basics so that later, it’s already second nature to be doing things the right way.

#6

Concatenation has worked for me consistently since I started using Python. (4 years)

#7

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