Q. Area of regular polygon can be computed as :
½ n sin (360 / n ) s2
Where n = number of sides and s = length from center to a corner .
Write a program to obtain values n and s from user and print area of polygon .
Answer =
import math s = float(input("Enter the length from center to a corner :- ")) n = int(input("Enter the number of sides :- ")) sin = math.sin(360 / n ) print ( 1/2 * n * sin * s ** 2)
Output :-
Enter the length from center to a corner :- 50
Enter the number of sides :- 8
8509.035245341185
>>>
Enter the length from center to a corner :- 89
Enter the number of sides :- 6
-7243.214789251975
>>>
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )