Live now! Full branding package giveaway worth $11,895. Join now

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

Get useful blogging, marketing and learning resources, delivered to your mailbox. Plus, get regularly updated with extra tools & guides to help you learn, grow and earn better.

Get 10 exclusive e-books & templates for free, to begin with. 🎁