{"id":7330,"date":"2021-09-30T11:30:56","date_gmt":"2021-09-30T06:00:56","guid":{"rendered":"https:\/\/python-programs.com\/?p=7330"},"modified":"2021-11-22T18:35:27","modified_gmt":"2021-11-22T13:05:27","slug":"python-program-to-calculate-the-area-semi-perimeter-and-perimeter-of-a-triangle","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-calculate-the-area-semi-perimeter-and-perimeter-of-a-triangle\/","title":{"rendered":"Python Program to Calculate the Area, Semi Perimeter and Perimeter of a Triangle"},"content":{"rendered":"

Practice Java programming from home without using any fancy software just by tapping on this Simple Java Programs for Beginners<\/a> tutorial.<\/p>\n

With an example, learn how to construct a Python program to find the Area of a Triangle, Perimeter of a Triangle, and Semi-Perimeter of a Triangle. Let’s look at the definitions and mathematics underlying Perimeter and Area of a Triangle before diving into the Python program to find Area of a Triangle.<\/p>\n

Area of Triangle:<\/strong><\/p>\n

If we know the lengths of the three sides of a triangle, we can use Heron’s Formula to compute the area of the triangle.<\/p>\n

Triangle Area = \u221a((s*(s-a)*(s-b)*(s-c)))<\/p><\/blockquote>\n

Where<\/p>\n

s = (a + b + c )\/ 2<\/pre>\n

(Here s = semi perimeter and a, b, c are the three sides of a given_triangle)<\/p>\n

Perimeter of a Triangle = a + b + c<\/pre>\n

Examples:<\/h2>\n

Example 1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

a = 24\r\nb = 12\r\nc = 22<\/pre>\n

Output:<\/strong><\/p>\n

The semiperimeter of the triangle with the sides 24 12 22 = 29.0\r\nThe perimeter of the triangle with the sides 24 12 22 = 58\r\nThe area of the triangle with the sides 24 12 22 =131.358<\/pre>\n

Example 2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

a = 5.6\r\nb = 2.7\r\nc = 7.9<\/pre>\n

Output:<\/strong><\/p>\n

The semiperimeter of the triangle with the sides 5.6 2.7 7.9 =8.100\r\nThe perimeter of the triangle with the sides 5.6 2.7 7.9 =16.200\r\nThe area of the triangle with the sides 5.6 2.7 7.9 =4.677<\/pre>\n

Program to Calculate the Area, Semi Perimeter and Perimeter of a Triangle<\/h2>\n

Let us calculate the area, semi perimeter and perimeter of Triangle in Python:<\/p>\n