Computer Science, asked by AnjanaJayaraj, 9 months ago

write a python program to determine the shape from its number of sides​

Answers

Answered by sristi99132
1

Answer:

Ok

Explanation:

Answered by rommelgonsalvez
0

Answer:

Code May Help You.

import math

def polygon(sides, radius=1, rotation=0, translation=None):

   one_segment = math.pi * 2 / sides

   points = [

       (math.sin(one_segment * i + rotation) * radius,

        math.cos(one_segment * i + rotation) * radius)

       for i in range(sides)]

   if translation:

       points = [[sum(pair) for pair in zip(point, translation)]

                 for point in points]

   return points

Explanation:

here's a fair bit going on in there, so I'll talk through it. The basic approach is to sweep out a circle, and put n equally spaced points on it. These will be the points of our polygon, starting at the 12 'o' clock position.The first thing to do is work out the angle (in radians) of each wedge from the center outwards. The total number of radians in a circle is 2 pi, so our value is 2 pi / n per segment.

Similar questions