Skip to content

Commit de91f66

Browse files
authored
Create polysum.py
1 parent af4fb3a commit de91f66

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Diff for: polysum.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import math
2+
3+
4+
def polysum(n, s):
5+
'''
6+
Input: n - number of sides(should be an integer)
7+
s- length of each sides(can be an intger or a float)
8+
Output: Returns Sum of area and the square of the perimeter of the regular polygon(gives a float)
9+
'''
10+
# Code
11+
def areaOfPolygon(n, s):
12+
#Pi = 3.1428
13+
area = (0.25 * n * s ** 2)/math.tan(math.pi/n)
14+
return area
15+
16+
def perimeterOfPolygon(n, s):
17+
perimeter = n * s
18+
return perimeter
19+
sum = areaOfPolygon(n, s) + (perimeterOfPolygon(n, s) ** 2)
20+
return round(sum, 4)
21+
22+
23+
print(polysum(76, 67))

0 commit comments

Comments
 (0)