Let’s see how the grades varied against the average. This is called computing the variance.
A very large variance means that the students’ grades were all over the place, while a small variance (relatively close to the average) means that the majority of the students had similar grades.
On line 18, define a new function called
grades_variance that accepts one argument,
scores, a list.
First, create a variable
average and store the result of calling
Next, create another variable
variance and set it to zero. We will use this as a rolling sum.
score in scores: Compute its squared difference:
(average - score) ** 2 and add that to
Divide the total
variance by the number of
Then, return that result.
Finally, after your function code,