Python program to find the area of a triangle. It is a simple computer program in python language and necessary one for beginners, class 11 and 12 and B Tech Lab practical. Download source code.

**AIM : Python program to find the area of a triangle**

### How the program works?

- The program first accept the sides of the triangle.
- Mathematical calculation as per formula.
- Output is provided on the screen.

### Explaination:

The three side of triangle are inputted as a,b,c.

s, (semi perimeter) is calculated by the formula (a+b+c)/2**Mathematical formula:**

Area of a triangle = (s*(s-a)*(s-b)*(s-c))^{1/2 }

Here s is the semi-perimeter and a, b and c are three sides of the triangle.

Output is given as float value.

### Source code:

```
# Three sides of the triangle is a, b and c:
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)
```

### Click below button to Download Source Code

### Output:

### Output Explanation:

Three sides of the triangle is a, b and c are accepted by the sentence shown to input which is in ‘ ‘ quotes.

a = float(input(‘Enter first side: ‘))

b = float(input(‘Enter second side: ‘))

c = float(input(‘Enter third side: ‘))

calculate the area Printed:

area = (s*(s-a)*(s-b)*(s-c)) ** 0.5

print(‘The area of the triangle is %0.2f’ %area)

Thank you for learning and reading from this post. The area of triangle checks your basic knowledge about computer science language like python keywords and mathematical concepts. This is one of the basic and simple program that calculates the area of triangle. There are 3 input asked and 1 output given by the shell command page after the script is run. Their are more programs with source code to practice. Check below for the link. All the programs are useful if you have taken class 11 and 12 computer science or computer science engineering in your graduation.

- Python program to print “Hello Python” – CS Study
- Python Practical File for AKTU B Tech – CS Study
- Computer Science with Python Practical Book Solutions Class 11 Term -2 – CS Study
- Computer Science Practical file for class 12 Term-2 – CS Study