# Write a Python Program to Calculate the Area of a Triangle

In this tutorial you will learn to write a simple Python program to calculate the Area of a Triangle when values of three sides are provided.

## Formula to Calculate area of the Triangle.

When all three sides of the triangle are known, we can use **Heron's formula** to calculate the area.

If a, b and c are three sides of a triangle, then first we calculate the **Semi Perimeter** using the formula

s = (a+b+c)/2

here **s** will contain **Semi Perimeter**

After that we calculate Area using the formula

Area = √(s(s-a)*(s-b)*(s-c))

### Python example program

```
1 # Python Program to find the area of triangle
2
3 # Get sides of the Triangle from the user
4 a = float(input('Enter first side: '))
5 b = float(input('Enter second side: '))
6 c = float(input('Enter third side: '))
7
8 # calculate the Semi Perimeter
9 s = (a + b + c) / 2
10
11 # calculate the Area
12 area = (s*(s-a)*(s-b)*(s-c)) ** 0.5
13
14 # Display Result
15 print('The area of the triangle is %0.2f' %area)
```

#### Program Output : Run 1

Enter first side: 5

Enter second side: 6

Enter third side: 4

The area of the triangle is 9.92