From d4bf4b41f4f0d6d163958b536bbe33317787c4e2 Mon Sep 17 00:00:00 2001 From: Zeeshan Latif <67405028+Zeeshan6781@users.noreply.github.com> Date: Thu, 1 Oct 2020 06:31:50 +0500 Subject: [PATCH] Create Polygon.py --- Polygon.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Polygon.py diff --git a/Polygon.py b/Polygon.py new file mode 100644 index 0000000..885c0e6 --- /dev/null +++ b/Polygon.py @@ -0,0 +1,25 @@ +import math + + +def polysum(n, s): + ''' + Input: n - number of sides(should be an integer) + s- length of each sides(can be an intger or a float) + + Output: Returns Sum of area and the square of the perimeter of the regular polygon(gives a float) + ''' + # Code + def areaOfPolygon(n, s): + #Pi = 3.1428 + area = (0.25 * n * s ** 2)/math.tan(math.pi/n) + return area + + def perimeterOfPolygon(n, s): + perimeter = n * s + return perimeter + sum = areaOfPolygon(n, s) + (perimeterOfPolygon(n, s) ** 2) + return round(sum, 4) + + +print(polysum(76, 67)) +