Write a program in Python to input the length of base and height of a right-angled triangle and print the length of the hypotenuse
Answers
Answered by
4
In a right angled triangle:
→ Hypotenuse² = Height² + Base²
→ Hypotenuse = √(Height² + Base²)
Take the height and base of the triangle as input and substitute their value in the formula to get the desired result!
from math import sqrt
base=eval(input('Enter base: '))
height=eval(input('Enter height: '))
hypotenuse=sqrt(base * base + height * height)
print('Hypotenuse of the triangle is',hypotenuse,'unit.')
Enter base: 3
Enter height: 4
Hypotenuse of the triangle is 5.0 unit.
See attachment for verification!
Attachments:
Similar questions