9/9 Review: It looks like not all grades were printed


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/courses/learn-python/lessons/exam-statistics/exercises/review-2?action=lesson_resume&link_content_target=interstitial_undefined

<In what way does your code behave incorrectly? Include ALL error messages.>
It looks like not all grades were printed! Make sure you are printing each one on their own line.

This is the output:

334.071005917
18.2776094147
[100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5]
1045.5
80.4230769231
334.071005917
18.2776094147

<What do you expect to happen instead?>
I don’t know why this isn’t working.


def print_grades(grades_input):
  for grade in grades_input:
    print grade

def grades_sum(scores):
  total = 0
  for score in scores: 
    total += score
  return total
    
def grades_average(grades_input):
  sum_of_grades = grades_sum(grades_input)
  average = sum_of_grades / float(len(grades_input))
  return average

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

print grades_variance(grades)
    
def grades_std_deviation(variance):
  deviation = variance ** 0.5
  return deviation
  
variance = grades_variance(grades)

print grades_std_deviation(variance)

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



#2

you do print the grades:


print grades

which results in the following output:

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

if we then study the error message:

Make sure you are printing each one on their own line.

All your grades are printed on a single line, not each grade on its own line

which is why you get an error message. Did we write a function which print each grade on its own line?


#3

I wasn’t calling the function, got it! Thanks.


#4

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