Area Of Equilateral Triangle In Python

                 

    Area Of Equilateral Triangle In Python

This is how an equilateral triangle looks like:

Equilateral Triangle

As you can see, this is an equilateral triangle with a side length of “a” units and a height of “h” units.

The altitude of an equilateral triangle cuts the opposite side at right angles. So, by using the Pythagoras theorem, we can calculate the height of an equilateral triangle to be sqrt(3/4)a.

Thus, the area of an equilateral triangle = 1/2 * sqrt (3/4)a * a

Area = (sqrt 3)/4 * a^2

Program:

    import math
    a=float(input("enter side of the triangle: "));
    area=(math.sqrt(3)/4)*a*a;
    print("Area Of Equilateral Triangle ",area);

    OutPut:
    enter side of the triangle: 10
    Area Of Equilateral Triangle  43.301270189221924



























    No comments:

    Post a Comment