Answer to Question #222376 in Python for srikanth

Question #222376
Compute Hypotenuse

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-08-09T02:33:34-0400
a = float(input())
b = float(input())

c = a*a + b*b

print(c**0.5)

Input 1:
3
4
Output 1:
5.0

Input 2:
12
5
Output 2:
13.0

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
New on Blog
APPROVED BY CLIENTS