(Geometry: area of a pentagon) Write a program that prompts the user to enter the
length from the center of a pentagon to a vertex and computes the area of the pen-
tagon, as shown in the following figure.
3V3
The formula for computing the area of a pentagon is Area =
2
where s is
the length of a side. The side can be computed using the formula s = 2r sin
where r is the length from the center of a pentagon to a vertex. Here is a sample
run:
Enter the length from the center to a vertex: 5.5
The area of the pentagon is 108.61
JEnter
from math import sin, pi, sqrt
a = float(input("Enter the length from the center to a vertex: "))
s = 2 * a * sin(pi/5)
area = ((3*sqrt(3))/2)*s**2
print("The area of the pentagon is", round(area,2))
Comments
Leave a comment