Created
July 16, 2014 09:33
-
-
Save jnrbsn/841fc91e6bbd80d6bb2c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def degrees_to_direction(degrees): | |
"""Convert degrees to a compass direction.""" | |
directions = [ | |
'N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', | |
'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW', | |
] | |
return directions[int(round(float(degrees) / 22.5)) % 16] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment