# Exercise 1: exposed population for each village around the hypothetical volcano villages = [("Aldwick", 4, 1200), ("Brae", 12, 5000), ("Corrie", 28, 20000), ("Dunmore", 45, 80000)] def zone(distance_km): if distance_km <= 5: return "red" if distance_km <= 15: return "orange" if distance_km <= 30: return "yellow" return "green" weight = {"red": 1.0, "orange": 0.4, "yellow": 0.1, "green": 0.0} # invented exposure weights total = 0 for name, distance, population in villages: z = zone(distance) exposed = population * weight[z] total += exposed print(f"{name:8s} {distance:3d} km {z:7s} exposed {exposed:7.0f}") print(f"total exposed: {total:.0f}") # Aldwick 4 km red exposed 1200 # Brae 12 km orange exposed 2000 # Corrie 28 km yellow exposed 2000 # Dunmore 45 km green exposed 0 # total exposed: 5200 # Dunmore is the biggest town but has zero exposure here, while tiny Aldwick is fully exposed. # Risk depends on hazard AND exposure, so the largest population is not automatically the first priority.