티스토리 뷰

IT/Python: Codecademy

9 Exam Statistics

Last72 2018. 3. 6. 09:07

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


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

  variance /= float(len(scores))

  return variance


def grades_std_deviation(variance):

  return variance ** 0.5


variance = grades_variance(grades)


print print_grades(grades)

print grades_sum(grades)

print grades_average(grades)

print grades_variance(grades)

print grades_std_deviation(variance)



'IT > Python: Codecademy' 카테고리의 다른 글

Sec10: bit calculator  (0) 2018.03.08
10 Advanced Topics in Python  (0) 2018.03.07
8 Loop  (0) 2018.02.28
7 Lists and Functions  (0) 2018.02.26
6 Student Becomes the Teacher  (0) 2018.02.24
댓글
Announcement
Recent Posts
Recent Comments
Total
Today
Yesterday
Link
TAG
more
«   2024/12   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
Search by month