# Exercise 2: counting the seconds between a flash and its sound. import math def v_air(celsius): return math.sqrt(1.4 * 8.314462618 * (celsius + 273.15) / 0.0289645) # Part 1: distance from the flash-to-bang lag at 10 C (still air assumed). for lag in (2, 5, 10, 20): print(lag, "s lag ->", round(lag * v_air(10)), "m") # Part 2: the error from using a rule of 343 m/s on a cold day (0 C) and a warm one (30 C). for t in (0, 30): err = 100 * (343 - v_air(t)) / v_air(t) print(t, "C: using 343 m/s is", round(abs(err), 1), "% too", "far" if err > 0 else "short") # Part 3: a signal heard at 3 nautical miles, then the model against the 1738 Paris figure of 332 m/s at 0 C. d = 3 * 1852 print("3 nm at 15 C:", round(d / v_air(15), 1), "s") print("model at 0 C:", round(v_air(0), 1), "vs 332 -> difference", round(332 - v_air(0), 1), "m/s") print("Newton's 979 ft/s =", round(979 * 0.3048), "m/s,", round(100 * (979 * 0.3048 - v_air(20)) / v_air(20), 1), "% against the model at 20 C") # 2 s lag -> 675 m # 5 s lag -> 1687 m # 10 s lag -> 3373 m # 20 s lag -> 6747 m # 0 C: using 343 m/s is 3.5 % too far # 30 C: using 343 m/s is 1.7 % too short # 3 nm at 15 C: 16.3 s # model at 0 C: 331.3 vs 332 -> difference 0.7 m/s # Newton's 979 ft/s = 298 m/s, -13.1 % against the model at 20 C