# File: hypotex.py # compute the hypotenuse of a right triangle # # ** this does no error checking ** # # Matt Bishop, MHI 289I, Fall 2024 # # bring in the square root function import math # # 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: print("you blew it! Not a number.") else: # looking good . . . do the computation and print the results z = math.sqrt(x ** 2 + y ** 2) print("A right triange with sides", x, "and", y, "has a hypotenuse of length", z) print(" (using the square root function)") z = (x ** 2 + y ** 2) ** (0.5) print("A right triange with sides", x, "and", y, "has a hypotenuse of length", z) print(" (using exponentiation)")