(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 pentagon, as shown in the following figure.
The formula for computing the area of a pentagon is Area = 33/2 s^2 where s is the length of a side. The side can be computed using the formula s = 2r sin pi/5 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
#Importing math module
import math
#Taking the input length from the user
print("Enter the length from the center to a vertex: ")
r = float(input())
#Compute the area of the pentagon
s = (2 * r) * math.sin(math.pi / 5)
area = ((3*math.sqrt(3))/2)*s**2
#Display results
print("The area of the pentagon is {:.2f}".format(area))
Output:
Enter the length from the center to a vertex:
5.5
The area of the pentagon is 108.61