Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from math import pi, tan
- def polysum(n, s):
- '''
- Input integer n is number of sides of a regular polygon
- Input: integer s is length of sides of a regular polygon
- Returns the sum of the area and the square of the perimeter of the polygon
- rounded to 4 decimal places
- '''
- def area(n, s):
- '''
- Input integer n is number of sides of a regular polygon
- Input: integer s is length of sides of a regular polygon
- Returns the area of the polygon
- '''
- numerator = 0.25 * n * s ** 2
- denominator = tan(pi / n)
- return numerator / denominator
- def perimSquare(n, s):
- '''
- Input: integer n is number of sides of a regular polygon
- Input: integer s is length of sides of a regular polygon
- Returns the square of the perimeter of the polygon
- '''
- return (n * s) ** 2
- a = area(n, s)
- p = perimSquare(n, s)
- return round(a + p, 4)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement