1+ from scipy .constants import g
12"""
23Title : Computing the terminal velocity of an object falling
34 through a fluid.
1314where :
1415Vt = Terminal velocity (in m/s)
1516m = Mass of the falling object (in Kg)
16- g = Acceleration due to gravity (value taken : 9.8 m/s^2 )
17+ g = Acceleration due to gravity (value taken : imported from scipy )
1718ρ = Density of the fluid through which the object is falling (in Kg/m^3)
1819A = Projected area of the object (in m^2)
1920Cd = Drag coefficient (dimensionless)
@@ -27,11 +28,11 @@ def terminal_velocity(
2728) -> float :
2829 """
2930 >>> terminal_velocity(1, 25, 0.6, 0.77)
30- 1.3026778945578592
31+ 1.3031197996044768
3132 >>> terminal_velocity(2, 100, 0.45, 0.23)
32- 1.9461345311993645
33+ 1.9467947148674276
3334 >>> terminal_velocity(5, 50, 0.2, 0.5)
34- 4.427188724235731
35+ 4.428690551393267
3536 >>> terminal_velocity(-5, 50, -0.2, -2)
3637 Traceback (most recent call last):
3738 ...
@@ -49,7 +50,7 @@ def terminal_velocity(
4950 raise ValueError (
5051 "mass, density, area and the drag coefficient all need to be positive"
5152 )
52- return ((2 * mass * 9.8 ) / (density * area * drag_coefficient )) ** 0.5
53+ return ((2 * mass * g ) / (density * area * drag_coefficient )) ** 0.5
5354
5455
5556if __name__ == "__main__" :
0 commit comments