The thing to keep in mind is that when written as a callback, we have created a dependency. As a consideration, the whole process could be refactored into one function that takes a list of grades, then does the computation locally. But that means we cannot find variance, except to depend upon this function for it.

```
sigma = grades_standard_deviation(grades) # assumes function in place
variance = sigma ** 2
```

```
def grades_standard_deviation(s):
n = len(s)
u = float(sum(s)) / n
q = lambda x: (x - u) ** 2
return (sum([ q(k) for k in s ]) / n) ** 0.5
# --- variance ---
grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5]
print grades_standard_deviation(grades) # 18.2776094147
```

##
Code

```
def grades_standard_deviation(s):
n = len(s)
u = float(sum(s)) / n
q = lambda x: (x - u) ** 2
return (sum([ q(k) for k in s ]) / n) ** 0.5
# --- variance ---
grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5]
sigma = grades_standard_deviation(grades)
variance = sigma ** 2
print sigma # 18.2776094147
print variance # 334.071005917
```