Advertisement
superiqbal7

Standard diviation & variance of grades

Mar 23rd, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.70 KB | None | 0 0
  1. grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5]
  2.  
  3. def print_grades(grades_input):
  4.   for grade in grades_input:
  5.     print grade
  6.  
  7. def grades_sum(scores):
  8.   total = 0
  9.   for score in scores:
  10.     total += score
  11.   return total
  12.    
  13. def grades_average(grades_input):
  14.   sum_of_grades = grades_sum(grades_input)
  15.   average = sum_of_grades / float(len(grades_input))
  16.   return average
  17.  
  18. def grades_variance(grades):
  19.     variance = 0
  20.     for number in grades:
  21.         variance += (grades_average(grades) - number) ** 2
  22.     return variance / len(grades)
  23.  
  24. def grades_std_deviation(variance):
  25.   return variance ** 0.5
  26.  
  27. variance = grades_variance(grades)
  28.  
  29. print grades_std_deviation(variance)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement