#
# Given the lengths of the two legs of a right triangle,
# compute the length of the hypotenuse using the
# Pythagorean theorem
#
#
# Matt Bishop, MHI 289I, Fall 2021
#
## Load the math module so we can use the sqrt method
import math
##
## Indefinite loop; exit is at the end using a "break"
##
while True:
# read in a, b
try:
a = float(input("First side: "))
b = float(input("Second side: "))
except:
## Something entered was not a float
print("One of these is not a float!!!!!")
else:
## check the lengths of the sides are non-negative
if a < 0 or b < 0:
print("Both numbers must be non-negative")
else:
# compute sqrt of a^2 and b^2
c = math.sqrt(a**2 + b**2)
# print it
print("The length of the hypotenuse is", c)
# ask user if she wants to continue
contin = input("Do you want to continue? (y or n): ")
## if anything other than "y" or "n", ask again
while contin != "y" and contin != "n":
print("y or n only, please!")
contin = input("Do you want to continue? (y or n): ")
## if user typed "n", quit
if (contin == "n"):
break