title computing the terminal velocity of an object falling through a fluid terminal velocity is defined as the highest velocity attained by an object falling through a fluid it is observed when the sum of drag force and buoyancy is equal to the downward gravity force acting on the object the acceleration of the object is zero as the net force acting on the object is zero vt 2 m g a cd0 5 where vt terminal velocity in ms m mass of the falling object in kg g acceleration due to gravity value taken imported from scipy density of the fluid through which the object is falling in kgm3 a projected area of the object in m2 cd drag coefficient dimensionless reference https byjus comphysicsderivationofterminalvelocity terminalvelocity1 25 0 6 0 77 1 3031197996044768 terminalvelocity2 100 0 45 0 23 1 9467947148674276 terminalvelocity5 50 0 2 0 5 4 428690551393267 terminalvelocity5 50 0 2 2 traceback most recent call last valueerror mass density area and the drag coefficient all need to be positive terminalvelocity3 20 1 2 traceback most recent call last valueerror mass density area and the drag coefficient all need to be positive terminalvelocity2 1 0 44 1 traceback most recent call last valueerror mass density area and the drag coefficient all need to be positive terminal_velocity 1 25 0 6 0 77 1 3031197996044768 terminal_velocity 2 100 0 45 0 23 1 9467947148674276 terminal_velocity 5 50 0 2 0 5 4 428690551393267 terminal_velocity 5 50 0 2 2 traceback most recent call last valueerror mass density area and the drag coefficient all need to be positive terminal_velocity 3 20 1 2 traceback most recent call last valueerror mass density area and the drag coefficient all need to be positive terminal_velocity 2 1 0 44 1 traceback most recent call last valueerror mass density area and the drag coefficient all need to be positive
from scipy.constants import g


def terminal_velocity(
    mass: float, density: float, area: float, drag_coefficient: float
) -> float:
    
    if mass <= 0 or density <= 0 or area <= 0 or drag_coefficient <= 0:
        raise ValueError(
            "mass, density, area and the drag coefficient all need to be positive"
        )
    return ((2 * mass * g) / (density * area * drag_coefficient)) ** 0.5


if __name__ == "__main__":
    import doctest

    doctest.testmod()