Question: Write a function named hypotenuse(num1, num2) that returns the length of the hypotenuse of a right angle triangle geometric with sides of length num1

Write a function named hypotenuse(num1, num2) that returns the length of the hypotenuse of a right angle

Write a function named hypotenuse(num1, num2) that returns the length of the hypotenuse of a right angle triangle geometric with sides of length num1 and num2 i.e. sqrt{num1**2 + num2**2} If at least one of the arguments num1, num2 is not a numerical value, the function prints "Cannot compute the hypotenuse!" in the console and exits without crashing the rest of the program. If at least one of the arguments num1, num2 are 0 or negative, the function prints "Triangle sides must be greater than 0!" in the console and exits without crashing the rest of the program. You should use Python's exception handling in this task. [3 marks]

Step by Step Solution

3.36 Rating (152 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres an example of how you could implement t... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!