 # Python Program to Find Area of Triangle

Python program to find area of triangle; In this tutorial, you will learn how to find or calculate area of a triangle in python.

The area of a polygon is the number of square units inside that polygon. … A triangle is a three-sided polygon. We will look at several types of triangles in this lesson. To find the area of a triangle, multiply the base by the height, and then divide by 2.

Find Area of Triangle Formula; as shown below:

`Area of a Triangle = √(s*(s-a)*(s-b)*(s-c))`

Where s = (a + b + c )/ 2 (Here s = semi perimeter and a, b, c are the three sides of a triangle)

`Perimeter of a Triangle = a + b + c`

## Python Program to Find Area of Triangle

• Simple Python Program to Find the Area of a Triangle
• Python Program to Find the Area of a Triangle using Function

### Simple Python Program to Find the Area of a Triangle

Follow the below steps and write a python program to find area of triangle:

• Allow the user to input the triangle sides.
• Calculate the Perimeter of Triangle using the formula P = a+b+c.
• Calculating the semi perimeter using the formula (a+b+c)/2.
• Calculating the Area of a triangle using Heron’s Formula: (s*(s-a)*(s-b)*(s-c)) ** 0.5.
• Print the Area of a triangle.
```# Python Program to find Area of a Triangle

a = float(input('Please Enter the First side of a Triangle: '))
b = float(input('Please Enter the Second side of b Triangle: '))
c = float(input('Please Enter the Third side of c Triangle: '))

# calculate the Perimeter
Perimeter = a + b + c

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

# calculate the area
Area = (s*(s-a)*(s-b)*(s-c)) ** 0.5

print("\n The Perimeter of Traiangle = %.2f" %Perimeter);
print(" The Semi Perimeter of Traiangle = %.2f" %s);
print(" The Area of a Triangle is %0.2f" %Area)
```

After executing the python program, the output will be:

```Please Enter the First side of a Triangle:  5
Please Enter the Second side of b Triangle:  4
Please Enter the Third side of c Triangle:  3

The Perimeter of Traiangle = 12.00
The Semi Perimeter of Traiangle = 6.00
The Area of a Triangle is 6.00```

### Python Program to Find the Area of a Triangle using Function

Follow the below steps and write a python program to find the area of triangle using function:

• Import math module.
• Defined the function with three arguments using def keyword.
• Calculate the perimeter and Area of a triangle inside functions using math.sqrt() and with Heron’s Formula.
• Allow the User to input the sides of triangle.
• Print the Perimeter and Area of a triangle.
```# Python Program to find Area of a Triangle using Functions

import math

def AreaOfTriangle(a, b, c):

# calculate the Perimeter
Perimeter = a + b + c

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

# calculate the area
Area = math.sqrt((s*(s-a)*(s-b)*(s-c)))

print("\n The Perimeter of Traiangle = %.2f" %Perimeter);
print(" The Semi Perimeter of Traiangle = %.2f" %s);
print(" The Area of a Triangle is %0.2f" %Area)

a = float(input('Please Enter the First side of a Triangle: '))
b = float(input('Please Enter the Second side of b Triangle: '))
c = float(input('Please Enter the Third side of c Triangle: '))

AreaOfTriangle(a, b, c)
```

After executing the python program, the output will be:

```Please Enter the First side of a Triangle:  10
Please Enter the Second side of b Triangle:  15
Please Enter the Third side of c Triangle:  20

The Perimeter of Traiangle = 45.00
The Semi Perimeter of Traiangle = 22.50
The Area of a Triangle is 72.62```

## Recommended Python Programs 