Variance measures how spread out a list of numbers is. A tight cluster gives a small variance; numbers scattered all over give a large one.
You build it in three moves:
Task: write sample_variance(values) returning that average, rounded to 4 decimal places.
There is one catch, and it is the entire point of this problem: in step 3, divide by n - 1, not by n.
n - 1 gives the sample variance — the right choice when your list is a sample drawn from some larger population you can't fully see, which is nearly always the case. Dividing by n would quietly underestimate the real spread.values always holds at least two numbers, so n - 1 is never zero.0 every time.