Speed#
- pyquations.conversions.speed.speed(speed: float, from_unit: str, to_unit: str) float [source]
Converts a speed value from one unit to another.
- Supported units:
“mph” (miles per hour)
“kph” (kilometers per hour)
“mps” (meters per second)
“fps” (feet per second)
“knots” (nautical miles per hour)
“cm/s” (centimeters per second)
“ips” (inches per second)
- Parameters:
speed (float) – The speed value to convert. Must be non-negative.
from_unit (str) – The unit of the input speed. Must be one of the supported units.
to_unit (str) – The unit to convert the speed to. Must be one of the supported units.
- Returns:
The converted speed value.
- Return type:
float
- Raises:
ValueError – If the speed is negative or if the units are invalid.
Examples
>>> speed(60, "mph", "kph") 96.56064
>>> speed(100, "kph", "mps") 27.7778
>>> speed(30, "fps", "ips") 360.0
>>> speed(10, "mps", "knots") 19.4384