Mean of a List

Probability and StatisticsEasy+10 XP+10

Mean of a List

The mean is the "add it all up and share it out evenly" average: total the values, then divide by how many there are.

Task: write mean(values) returning that average, rounded to 4 decimal places.

What you can count on:

  • values is a list of numbers and is never empty, so you'll never divide by zero.
  • The numbers can be whole or decimal, positive or negative. Order doesn't matter here — adding them up gives the same total either way.
  • Return a single number, not a list.

Watch what the last test does to your answer: one value far from the rest pulls the mean toward itself, because every value gets an equal say in the total.

Mean Balance Lab

Explore the arithmetic mean as a fair share or a physical balance point.

Sum0
Count (N)0
FormulaSumN\dfrac{\text{Sum}}{N}NSum​=0.00

Examples

values = [3, 1, 4, 1, 5]
returns 2.8
values = [7, 2, 9, 4]
returns 5.5

Hints

Solve it to unlock the solution

Once your code passes every test, a reference solution shows up here so you can compare it with yours.

solution.py
CtrlEnterto run