To find a triangle’s area, we need to multiply the length of the base times the height. The area of a triangle is the number of square units required to cover the two sides that meet at the triangle’s base. The height of the triangle is perpendicular to this side, so it can be drawn on top of one side. The length of this base can be found by multiplying together the lengths of the two sides that meet at this point. The area of a triangle is the number of square units required to cover the base multiplied by the height. The area formula for a triangle with A as its base and height h is given by: A =½ (b x h)
This is a sample Python Program to calculate the area of a triangle.
# Python Program to Calculate the Area of a Triangle # take input number from user b = int(input("Input the base : ")) h = int(input("Input the height : ")) # calculate the area area = 1/2*b*h print("Area of a Triangle = ", area)
Input the base : 20 Input the height : 40 Area of a Triangle = 400.0