Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

Heres an example of how you could implement t... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Java Software Structures Designing And Using Data Structures

Authors: John Lewis, Joe Chase

4th Edition

0133250121, 978-0133250121

More Books

Students also viewed these Programming questions