1
1
Fork 0

Merge branch 'master' of https://www.coastalcommits.com/Seaswimmer/PythonLearning
All checks were successful
Lint Code / Ruff (push) Successful in 7s
Lint Code / MyPy (push) Successful in 9s
Lint Code / Pylint (push) Successful in 8s

This commit is contained in:
Seaswimmer 2024-05-23 21:41:16 -04:00
commit 23c0fa2e9f
Signed by: cswimr
GPG key ID: 5D671B5D03D65A7F

23
Hypotenusenuse/main.py Normal file
View file

@ -0,0 +1,23 @@
from math import sqrt
def calculate_hypotenuse(
x: float, y: float
) -> float: # This function will calculate our hypotenuse
x = float(
x
) # These 2 parts are both checks to attempt to convert our input into floats
y = float(y)
return sqrt(
x**2 + y**2
) # If we're able to convert both of our inputs into floats, we return our result
if __name__ == "__main__":
x = input("Input your A: ")
y = input("Input your B: ")
try:
result = calculate_hypotenuse(x, y)
print(f"{round(result)} ({result})")
except ValueError:
print("Error! Please do not input strings.")