Simple function
- fancy_calcy.triangle.calculate_hypotenuse(base, height)[source]
Calculate the hypotenuse of a right triangle.
- Parameters:
base (float) – The length of the base of the triangle.
height (float) – The height of the triangle.
- Returns:
The length of the hypotenuse.
- Return type:
float
- Raises:
ValueError – If base or height is not a positive number.
Note
We utilize the Pythagorean theorem to calculate the hypotenuse:
\[a^2 + b^2 = c^2\]- where
c is the hypotenuse
a and b are the base and height of the triangle, respectively.
Examples
>>> from fancy_calcy.triangle import calculate_hypotenuse >>> calculate_hypotenuse(3, 4) 5.0 >>> calculate_hypotenuse(5, 12) 13.0