Mar-11-2021, 09:15 PM
Thanks, deanhysad.
Here a further improvement with your suggestion and other bits:
Here a further improvement with your suggestion and other bits:
def pythagoras(h=None, x=None, y=None): '''Pythagorean Theorem: The area of the square whose side is the hypotenuse is equal to the sum of the areas of the squares on the other two sides.''' try: if h is None: return sqrt(x ** 2 + y ** 2) elif x is None: return sqrt(h ** 2 - y ** 2) elif y is None: return sqrt(h ** 2 - x ** 2) else: return "No unknown values to calculate." except: return "Insufficient data." print(pitagoras(x=3, y=4)) # 5.0 print(pitagoras(h=5, x=3)) # 4.0 print(pitagoras(h=5, x=4)) # 3.0 print(pitagoras(h=5, x=4, y=4)) # No unknown values to calculate. print(pitagoras(h=5)) # Insufficient data. print(pitagoras(x=4)) # Insufficient data. print(pitagoras(y=4)) # Insufficient data.