# Codecademy Python Answers Exam Statistics

### Exam Statistics 1/9 – Let’s Look at those Grades!

grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5] print "Grades:", grades

### Exam Statistics 2/9 – Print those Grades

grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5] def print_grades(grades): for i in grades: print i print_grades(grades)

### Exam Statistics 3/9 – Review

print "Let's compute some stats!"

### Exam Statistics 4/9 – The Sum of Scores

grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5] def grades_sum(scores): total = 0 for i in scores: total = total + i print total return total grades_sum(grades)

### Exam Statistics 5/9 – Computing the Average

grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5] def grades_sum(scores): total = 0 for i in scores: total = total + i return total def grades_average(grades): ptp = grades_sum(grades)/float(len(grades)) print ptp return ptp grades_average(grades)

### Exam Statistics 6/9 – Review

print "Time to conquer the variance!"

### Exam Statistics 7/9 – The Variance

grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5] def print_grades(grades): for grade in grades: print grade def grades_sum(grades): total = 0 for grade in grades: total += grade return total def grades_average(grades): sum_of_grades = grades_sum(grades) average = sum_of_grades / float(len(grades)) return average def grades_variance(scores): average = grades_average(scores) variance = 0 for score in scores: diff = (average - score) ** 2 variance += diff total = variance/float(len(scores)) return total print grades_variance(grades)

### Exam Statistics 8/9 – Standard Deviation

grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5] def print_grades(grades): for grade in grades: print grade def grades_sum(grades): total = 0 for grade in grades: total += grade return total def grades_average(grades): sum_of_grades = grades_sum(grades) average = sum_of_grades / float(len(grades)) return average def grades_variance(scores): average = grades_average(scores) variance = 0 for score in scores: diff = (average - score) ** 2 variance += diff total = variance/float(len(scores)) return total print grades_variance(grades) def grades_std_deviation(variance): return variance ** 0.5 variance = grades_variance(grades) grades_std_deviation(variance)

### Exam Statistics 9/9 – Review

grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5] def print_grades(grades): for grade in grades: print grade def grades_sum(grades): total = 0 for grade in grades: total += grade return total def grades_average(grades): sum_of_grades = grades_sum(grades) average = sum_of_grades / float(len(grades)) return average def grades_variance(scores): average = grades_average(scores) variance = 0 for score in scores: variance += (average - score) ** 2 result = variance / len(scores) return result print grades_variance(grades) def grades_std_deviation(variance): result = variance ** 0.5 return result print print_grades(grades) print grades_sum(grades) print grades_average(grades) print grades_variance(grades) print grades_std_deviation(grades_variance(grades))