Learn about Python Program to Find Area of Triangle in the below code example. Also, refer to the comments in the code snippet to get a detailed view about what’s actually happening.
Contents
Python Program to Find Area of Triangle
# python program to find the area of the right-angle triangle
# inputs
base = float(input('Enter the base of the triangle: '))
height = float(input('Enter the height of the triangle: '))
# calculating the area of triangle
area = (1/2) * base * height
# print result
print('Area of triangle = ',area)
Output:
Enter the base of the triangle: 2 Enter the height of the triangle: 5 Area of triangle = 5.0
Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.
Similar Code : Python Program to Find Area of Circle Using Function