Exercise 3 solution import random def gamete(rng, n): return tuple(rng.choice((0, 1)) for _ in range(n)) n = 3 rng = random.Random(11) trials = 100000 same = 0 for _ in range(trials): child1 = (gamete(rng, n), gamete(rng, n)) child2 = (gamete(rng, n), gamete(rng, n)) if child1 == child2: same += 1 print(same / trials, (1 / 2 ** n) ** 2) Output: 0.01583 0.015625 Reading it: Each child is a pair (one gamete from each parent). Two gametes match with chance 1/8, so both pairs match with chance (1/8) squared, 1/64 = 0.015625. The simulated fraction is close to it but not exact, because it is a random sample.