Instructions: You should submit your answer to this question as a Python code
with .py extension to the corresponding question in Google Classroom.
Attention: Make sure to write your name, surname, and student ID number.
Question:
(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 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 ter
The area of the pentagon is 108.61
import math
r = eval(input('length from the center of a pentagon to a vertex '))
s = 2 * r * math.sin(math.pi / 5)
print(5*s**2/(4*math.tan(math.pi/5)))
Comments
Leave a comment