How to calculate the area of a pentagon in Python

2 Answers

0 votes
def pentagon_area(side, apothem):
    return 5.0 * (side * apothem) / 2.0


side = 5.0
apothem = 3.0

area = pentagon_area(side, apothem)

print(f"Area = {area:.2f}")


"""
run:

Area = 37.50

"""

 



answered Jul 12, 2021 by avibootz
edited 6 hours ago by avibootz
0 votes
import math

def area_regular_pentagon(side):
    return (1/4) * math.sqrt(5 * (5 + 2 * math.sqrt(5))) * side**2

print(area_regular_pentagon(7))


'''
run:

84.30339262885938

'''


 



answered 3 hours ago by avibootz
...