Pythagorean Theorem#
- pyquations.geometry.pythagorean_theorem.pythagorean_theorem(a: float, b: float) float [source]
Calculates the length of the hypotenuse for a right triangle.
The area of the square whose side is the hypotenuse is equal to the sum of the areas of the squares on the other two sides. [1]
\[c^2 = a^2 + b^2\]Where:
\(a\) is the length of one leg of the triangle.
\(b\) is the length of the other leg of the triangle.
\(c\) is the length of the hypotenuse.
- Parameters:
a (float) – Length of one leg of the triangle. Must be non-negative.
b (float) – Length of the other leg of the triangle. Must be non-negative.
- Returns:
The length of the hypotenuse.
- Return type:
float
- Raises:
ValueError – If either ‘a’ or ‘b’ is not greater than 0.
Examples
>>> pythagorean_theorem(3, 4) 5.0
>>> pythagorean_theorem(5, 12) 13.0
>>> pythagorean_theorem(8, 15) 17.0
- Resources:
References