Site icon codemaniacstudio

Write a Python program to calculate area of an equilateral triangle.

Write a Python program to calculate area of an equilateral triangle.

SOLUTION....

# Program to calculate area of an equilateral triangle

import math   # for square root function

# Input
side = float(input("Enter the side of the equilateral triangle: "))

# Formula: (√3 / 4) × side²
area = (math.sqrt(3) / 4) * (side ** 2)

# Output
print(f"Area of the Equilateral Triangle = {area:.2f}")

OUTPUT

Exit mobile version