# Exercise 2: how wide is a cone of a given volume? import math def cone_radius(volume_km3, angle_deg): # V = pi * r^2 * h / 3 with h = r * tan(angle) -> r = (3V / (pi tan))^(1/3) return (3 * volume_km3 / (math.pi * math.tan(math.radians(angle_deg)))) ** (1 / 3) for name, angle in (("cinder cone", 33), ("stratovolcano", 25), ("shield", 3)): r = cone_radius(0.1, angle) h = r * math.tan(math.radians(angle)) print(f"{name:14s} 0.1 km3: radius {r:.2f} km, height {h*1000:5.0f} m") # cinder cone 0.1 km3: radius 0.53 km, height 343 m # stratovolcano 0.1 km3: radius 0.59 km, height 275 m # shield 0.1 km3: radius 1.22 km, height 64 m # For the same volume a steep cone is narrow and tall, a shield is wide and low: # slope controls the shape, volume controls the size.