Answer to Question #235260 in Python for vijay

Question #235260

Write a program to find the hypotenuse H of a right-angled triangle of sides A and B.


Note: Pythagoras theorem states that, for a right-angled triangle. Hypotenuse2 = A2 + B2


Input

The first line is an integer, A.

The second line is an integer, B.


Output

The output should be an integer.


Explanation

In the given example, the first side A = 3, and the second side B = 4. To calculate the hypotenuse we use Pythagoras theorem.


According to Pythagoras theorem, hypotenuse2 = 32 + 42


Therefore, the hypotenuse value is 5.

So, the output should be 5.


Sample Input 1

3

4

Sample Output 1

5

Sample Input 2

12

5

Sample Output 2

13



1
Expert's answer
2021-09-09T11:03:00-0400


def hypotenuse(s1, s2):
 
    hypo = (((s1 * s1) + (s2 * s2))**(1/2));
    return hypo;
 




print("Sample Input 1")
print(3)
print(4)
print("Sample output 1")
print(hypotenuse(3, 4));
print("\n")
print("Sample Input 2")
print(12)
print(5)
print("Sample output 2")
print(hypotenuse(5, 12));
 

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS