Skip to content

Instantly share code, notes, and snippets.

@lucpet
Last active December 21, 2015 23:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucpet/6384250 to your computer and use it in GitHub Desktop.
Save lucpet/6384250 to your computer and use it in GitHub Desktop.
Answer to the fundamentals facebook challenge
import math
def poly_area(n_sides, side_len):
''' (number, number) -> number
Calculates the area of a Polygon
using the length of one side
poly_area(7, 3)
>>> 32.705
'''
sides = n_sides
length = side_len
area = round(0.25 * sides * length ** 2 / math.tan(math.pi/sides), 3)
return area
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment