# prize35-6 Exercise 1: how long until a growing population passes 10,000? import math start, target = 100, 10000 births, deaths = 0.55, 0.15 r = births - deaths n, year = float(start), 0 while n < target: n = n + r * n year += 1 print(f"r = {r:.2f}; population passes {target} in year {year} (n = {n:.0f})") print(f"doubling time = {math.log(2) / math.log(1 + r):.1f} years") print(f"after 3 more years: {n * (1 + r) ** 3:.0f}") # Output: # r = 0.40; population passes 10000 in year 14 (n = 11112) # doubling time = 2.1 years # after 3 more years: 30491 # Reading it: growth of 40% per head per year doubles the population about every two years, so a hundred # animals pass ten thousand in 14 years, and the next three years add almost 20,000 more. Exponential growth # looks harmless early on and explosive late; in real life food, space or disease would stop it long before.