Python Program to Calculate the Area of a Triangle

Why do manual calculations when you can calculate the area of the triangle by writing few lines of code?
In this program, we will learn how to write a python program to calculate the perimeter and area of a triangle.
Mathematical formula:

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

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

Here %0.3f floating-point specifies that at least 0 wide and 2 numbers after the decimal should be displayed. If you use %0.4f then it will give 4 numbers after the decimal point.
for example: If your output is 12.354678 and you want to display only 2 numbers after the decimal point, then %0.2f will display 12.35

One comment

Leave a Reply