# Pythagorean theorem
def pythagorean_theorem(a, b):
"""
Calculates the length of the hypotenuse (c) of a right triangle
given the lengths of the other two sides (a and b) using
Pythagorean theorem: c^2 = a^2 + b^2
"""
c = (a**2 + b**2) ** 0.5
return c
# Example usage
a = 3
b = 4
c = pythagorean_theorem(a, b)
print(f"The length of the hypotenuse of the right triangle with sides {a} and {b} is {c}")
The pythagorean_theorem function takes in two parameters a and b which represent the lengths of the two shorter sides of a right triangle. It calculates the length of the hypotenuse c using the Pythagorean theorem and returns the result. The example usage demonstrates how to use the function to calculate the length of the hypotenuse for a right triangle with sides of length 3 and 4.
print ("")
print ("Pythagorean_Theorem a, b: ")
print ("Calculates the length of the hypotenuse (c) of a right triangle ")
print ("given the lengths of the other two sides (a and b) ")
print ("using Pythagorean theorem: c^2 = a^2 + b^2 ")
print ("")
print ("c = (a**2 + b**2) ** 0.5 return c ")
print ("")
print ("# Example usage ")
print ("a = 3, ")
print ("b = 4, ")
print ("c = pythagorean_theorem(a, b)")
print ("")
print ("++++++++++++++++++++++++++++++++++++")
print("")
a = float(input("Enter the length of side a: "))
b = float(input("Enter the length of side b: "))
c = (a**2 + b**2)**0.5 # square root of the sum of squares of a and b return c
print ("")
print ("++++++++++++++++++++++++++++++++++++")
print ("")
print (f"a^2= {a**2}")
print (f"b^2= {b**2}")
print (f"c^2= {a**2 + b**2}")
print ("")
print ("c^2 = a^2 + b^2 ")
print ("")
print ("++++++++++++++++++++++++++++++++++++")
print ("")
print(f"The length of the hypotenuse of the right triangle with sides, a = {a} and b = {b} is {c}")
print ("")
print ("++++++++++++++++++++++++++++++++++++")
print ("")
input("\n\nPress the Enter key to exit")