# Matt Bishop, MHI 289I
##
## This is the program we wrote in class on January 22
## I added a few comments (they begin with "##")
##
## Given the lengths of the two legs of a right triangle,
## computew the length of the hypotenuse using the
## Pythagorean theorem
##
## 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(raw_input("First side: "))
b = float(raw_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 c
# ask user if she wants to continue
contin = raw_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 = raw_input("Do you want to continue? (y or n): ")
## if user typed "n", quit
if (contin == "n"):
break