# Exercise 1: VEI from volumes given in cubic kilometres LIMITS = [1e4, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12] # lower limits for VEI 1..8, in m3 def vei(volume_m3): n = 0 for i, lim in enumerate(LIMITS): if volume_m3 >= lim: n = i + 1 return n def vei_km3(volume_km3): return vei(volume_km3 * 1e9) # 1 km3 = 1e9 m3 for name, v in (("small ash eruption", 0.0005), ("Eyjafjallajokull 2010", 0.27), ("Pinatubo 1991", 10), ("Tambora 1815", 150)): print(f"{name:22s} {v:8.4f} km3 -> VEI {vei_km3(v)}") # small ash eruption 0.0005 km3 -> VEI 1 # Eyjafjallajokull 2010 0.2700 km3 -> VEI 4 # Pinatubo 1991 10.0000 km3 -> VEI 6 # Tambora 1815 150.0000 km3 -> VEI 7 # Only the conversion changes: multiply by 1e9 and reuse the m3 function. # Volumes are rounded tephra figures for intuition (check).