Python program to calculate the area of an equilateral triangle
ADVERTISEMENTS
Python program to calculate the area of an equilateral triangle. There are you will learn how to find the area of an equilateral triangle in Python language.
Formula:
a = (sqrt(3) / 4) * (s * s)
Where:
a = area
s = side
Let us understand this example through the Python program:
# Python program to calculate the area of an equilateral triangle
import math # Used for sqrt() function
print("Enter the side of an equilateral triangle::")
s, a = float(input()), None
# s = side
# a = area
# Calculate area of equilateral triangle
a = (math.sqrt(3) / 4) * (s * s)
# Output
print("Area of the equilateral triangle = ", a, " sq. units")
Output:
Enter the side of an equilateral triangle::
7
Area of the equilateral triangle = 21.217622392718745 sq. units