# prize35-5 Exercise 2: dry months and the length of the dry season climates = { "Cape Town-like": ( [21, 21, 20, 17, 15, 13, 12, 13, 14, 16, 18, 20], [15, 17, 20, 41, 69, 93, 82, 77, 40, 30, 20, 17]), "Edinburgh-like": ( [4, 4, 6, 8, 11, 14, 16, 15, 13, 9, 6, 4], [50, 40, 40, 40, 50, 55, 70, 65, 60, 65, 60, 55]), } for name, (temps, rains) in climates.items(): dry_months = [m + 1 for m, (t, r) in enumerate(zip(temps, rains)) if r < 2 * t] if not dry_months: verdict = "no dry season" elif len(dry_months) <= 3: verdict = "short dry season" else: verdict = "long dry season" print(f"{name}: dry months {dry_months} -> {verdict}") # Output: # Cape Town-like: dry months [1, 2, 3, 10, 11, 12] -> long dry season # Edinburgh-like: dry months [] -> no dry season # Reading it: the Cape Town-like climate has two clear halves, a dry summer and a wet winter (six dry months # in the southern hemisphere's January-March and October-December), which is the signature of a # Mediterranean-type climate. The Edinburgh-like climate never dips below the line: modest rain in every month.