Exercise 3 solution import random from collections import Counter def score(rng, genes): return sum(rng.choice((0, 1)) + rng.choice((0, 1)) for _ in range(genes)) rng = random.Random(7) n = 50000 scores = [score(rng, 10) for _ in range(n)] c = Counter(scores) mean = sum(scores) / n middle = sum(c[s] for s in range(8, 13)) / n extreme = c[0] + c[20] print(round(mean, 3), round(middle, 3), extreme) print(min(scores), max(scores)) Output: 9.991 0.736 1 1 20 Reading it: the mean is very close to 10, half of the 20 possible alleles. About 74% of individuals score between 8 and 12, while the two ends are very rare: only 1 individual in 50,000 scored 0 or 20 (the exact chance of each end is 1 in 1,048,576, so a total of about 0.1 is expected; getting 1 is ordinary luck). The highest score seen was 20 and the lowest was 1.