Compute the Hypotenuse
Problem Description
Write a function that takes the lengths of the two shorter sides of a right triangle as its parameters. Return the hypotenuse of the triangle, computed using Pythagorean theorem, as the functions result.
Include a main program that reads the lengths of the shorter sides of a right triangle from the user, uses your function to compute the length of the hypotenuse, and displays the result.
Refer sample input and output for formatting specification.
All float values are displayed correct to 2 decimal places.
All text in bold corresponds to input and the rest corresponds to output
CODING ARENA
from math import sqrt
a=int(input())
b=int(input())
c=sqrt(a**2 + b**2)
print(c )
Test Case 1
Input (stdin)3
4
Expected Output
5
Test Case 2
Input (stdin)5
12
Expected Output
13
No comments:
Post a Comment