# How one can Calculate the world of a daily N sides polygon inside a circle of radius R in Python

0
8

## The problem#

Write the next operate:

``````def area_of_polygon_inside_circle(circle_radius, number_of_sides):
``````

It ought to calculate the world of a daily polygon of `numberOfSides``number-of-sides`, or `number_of_sides` sides inside a circle of radius `circleRadius``circle-radius`, or `circle_radius` which passes by all of the vertices of the polygon (such a circle is known as circumscribed circle or circumcircle). The reply needs to be a quantity rounded to three decimal locations.

Enter/Output Examples

``````area_of_polygon_inside_circle(3, 3) # returns 11.691
area_of_polygon_inside_circle(5.8, 7) # returns 92.053
area_of_polygon_inside_circle(4, 5) # returns 38.042
``````

## The answer in Python code#

Possibility 1:

``````from math import sin, pi

def area_of_polygon_inside_circle(r, n):
return spherical(0.5 * n * r ** 2 * sin(2 * pi / n), 3)
``````

Possibility 2:

``````import math
s = number_of_sides
a = (s * (r ** 2) * math.sin(2*math.pi/s))/2
return spherical(a, 3)
``````

Possibility 3:

``````from math import sin,cos,radians
``````take a look at.describe('Instance Exams')