"""How much a tapering biscuit tin overstates the rain.
Worked on the back of the 24 July page, then typed up. The tin is a frustum: 110 mm radius at the mouth, 98 mm at
the base, 95 mm deep. Rain is measured over the mouth; the ruler reads depth in a vessel that narrows below it.
"""frommathimportpiMOUTH_R=110.0# mmBASE_R=98.0# mmDEPTH=95.0# mmdefradius_at(h:float)->float:"""Radius of the water's surface h millimetres above the base."""returnBASE_R+(MOUTH_R-BASE_R)*h/DEPTHdefvolume_to(h:float)->float:"""Volume of water standing h millimetres deep, in cubic millimetres."""r0,r1=BASE_R,radius_at(h)returnpi*h*(r0*r0+r0*r1+r1*r1)/3defrain_for(reading:float)->float:"""Millimetres of rain over the mouth that leave `reading` millimetres standing in the tin."""returnvolume_to(reading)/(pi*MOUTH_R*MOUTH_R)if__name__=="__main__":forreadingin(1,5,12,41,80,95):rain=rain_for(reading)print(f"{reading:>3} mm in the tin = {rain:5.1f} mm of rain (overstated x{reading/rain:.2f})")
khosra
· khata 88cb5d68
· content 380f1670
· 228 publications, 4256671 bytes
· built in 1.495908104s