Create a new program called pythagorean.py .
In this program file, write one function named pythagorean .
This function will compute the length of the hypotenuse of a right triangle.
The function will accept two parameters (the length of the two sides of a right triangle adjacent to the 90-degree angle) and it will return the length of the hypotenuse.
Once you write the function, test it to ensure it works properly.
These tests:
print(pythagorean(1, 2))
print(pythagorean(5, 10))
print(pythagorean(12, 4))
Should produce this output:
2.23606797749979
11.180339887498949
12.649110640673518
Note that you might want to import the math module, and use math.sqrt() to compute a square root.
|