Sunday 11 October 2020

How to calculate the area of a triangle using a python program ?

 Calculating the area of a triangle is a very fundamental problem statement. Here I am explaining the calculation of the area of a triangle using Heron's Formula.

What is Heron's Formula ?

This is a formula which has been in use from the past 2000 year. We can easily calculate the area of a triangle if we know the measurement of all the three sides of a triangle.

 As shows in the picture above, if we know all the sides of the triangle a, b and c. We will be able to apply Heron's formula.

Area = (s(s-a) * (s-b) * (s-c)) ^ 0.5

where s = (a+b+c) / 2

We will use the above formula in a python program and make a utility to calculate the area in a programmatic way. 

The sample python program to calculate the area of triangle in given below

No comments:

Post a Comment

How to check the memory utilization of cluster nodes in a Kubernetes Cluster ?

 The memory and CPU utilization of a Kubernetes cluster can be checked by using the following command. kubectl top nodes The above command...