Python Online Compiler
Example: Python program to calculate the area of an equilateral triangle
C
C++
C#
Java
Python
PHP
main.py
STDIN
Run
# 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")
7
Output
Clear
ADVERTISEMENTS