FAQ: Variance - Average Distances

This community-built FAQ covers the “Average Distances” exercise from the lesson “Variance”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn Statistics With Python

FAQs on the exercise Average Distances

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

1 Like

I didn’t get the point of this session - both of the result is 0, what does it mean?

import numpy as np

grades = [88, 82, 85, 84, 90]
mean = np.mean(grades)

difference_one = 88 - mean
difference_two = 82 - mean
difference_three = 85 - mean
difference_four = 84 - mean
difference_five = 90 - mean

#Part 1: Sum the differences
difference_sum = difference_one + difference_two + difference_three + difference_four + difference_five

#Part 2: Average the differences
average_difference = difference_sum / 5

print("The sum of the differences is " + str(format(difference_sum, "f")))
print("The average difference is " + str(format(average_difference, "f")))


the line

mean = np.mean(grades)

should actually be

mean = np.average(grades)

Hi there’s an issue with the + str(format(difference_sum, “f”))), the “f” Displays fixed point number (Default: 6), so if you want to see the true value i suggest to add “.16f” instead of the “f” or put the value in the exponential form “e” instead of “f” (I suggest the exponential format

1 Like

Thank you for the kind explanation! I understand that the point is, positive and negative values ​​cancel each other out, and the result of the sum becomes too small.