Video 5 : Area of a Triangle using Heron Formula.
A triangle has many formulae to find its area. One formulae that involves only the sides of the triangle is the Heron’s formula or the Hero’s formula.
If \(a\), \(b\), and \(c\) are the sides of a triangle ABC, then the area of the triangle \(\Delta\) is given by
\[\Delta = \sqrt{s(s-a)(s-b)(s-c)}\]
where \(s = \displaystyle{\frac{a + b + c}{2}}\) is the semi-perimeter of the triangle.
'''
Program to calculate the area of a triangle using Heron's formulae
'''
# Get inputs
= float(input("Enter the side 'a' of the triangle:"))
a = float(input("Enter the side 'b' of the triangle:"))
b = float(input("Enter the side 'c' of the triangle:"))
c
# Calculate the semi-perimeter
= (a + b + c)*0.5
s
# Find the Area
= (s*(s-a)*(s-b)*(s-c))**0.5
Area
# Print the result
print("The area of the triangle with sides a = {}, b = {}, and c = {} is {}".format(a, b, c, Area))
Enter the side 'a' of the triangle:3
Enter the side 'b' of the triangle:4
Enter the side 'c' of the triangle:5
The area of the triangle with sides a = 3.0, b = 4.0, and c = 5.0 is 6.0