0542-2316689 | [email protected]

# Python Program-Area of Triangle

• In this Python Program-Area of Triangle, you’ll learn how to find the area of Triangle in Python

To properly understand this example to find the area of triangle in Python, you should have the knowledge of following Python programming topics:

Area of a triangle is equal to half of the product of its base and height.

The height of a triangle is the perpendicular distance from a vertex to the base of the triangle. (Note: 12 is the height, not the length of the left-hand side)

Height = h = 12

Base = b = 20

Area = ½ bh = ½ × 20 × 12 = 120

here if a, b, and c are three sides of the triangle so this can be solved by the mathematical formula

## Python Program to find the area of Triangle

```a = 5
b = 6
c = 7

# Uncomment below to take inputs from the user
# a = float(input('Enter first side: '))
# b = float(input('Enter second side: '))
# c = float(input('Enter third side: '))

# calculate the semi-perimeter
s = (a + b + c) / 2

# calculate the area
area = (s*(s-a)*(s-b)*(s-c)) ** 0.5
print('The area of the triangle is %0.2f' %area)```

Output

`The area of the triangle is 14.70`
• In this program, the area of the triangle is calculated when three sides are given using Heron’s formula.

Related Program

September 6, 2018