Answer to Question #228188 in Python for kaavya

Question #228188

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 + B2Input

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-22T07:16:24-0400
a = int(input())
b = int(input())
result = (a ** 2 + b ** 2) ** 0.5
print(int(result))

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