# File: hypot.py
# compute the hypotenuse of a right triangle
#
# Matt Bishop, MHI 289I, Fall 2020
#
# bring in the square root function
from math import sqrt
#
# read in the length of the two sides, as floats
# note we handle non-numbers as an exception here!
#
try:
x = float(input("First side: "))
y = float(input("Second side: "))
except:
# whatever was entered wasn't a floating point number
print("You need to enter a number for the length of the right triangle's side!")
else:
if x <= 0 or y <= 0:
print("Positive numbers only please!")
else:
# looking good . . . do the computation
z = sqrt(x ** 2 + y ** 2)
print("A right triange with sides", x, "and", y, "has a hypotenuse of length", z)
z = (x ** 2 + y ** 2) ** (0.5)
print("A right triange with sides", x, "and", y, "has a hypotenuse of length", z)