Computer Science, asked by aabcdefghijklma, 2 days ago

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 anindyaadhikari13
4

\texttt{\textsf{\large{\underline{Hint!}}}}

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!

\texttt{\textsf{\large{\underline{The C{o}de!}}}}

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.')

\texttt{\textsf{\large{\underline{Sample I/O!}}}}

Enter base: 3

Enter height: 4

Hypotenuse of the triangle is 5.0 unit.

See attachment for verification!

Attachments:
Similar questions