Skip to content

Instantly share code, notes, and snippets.

@alertor
Created August 28, 2014 12:03
Show Gist options
  • Save alertor/29839500922a75cb2b61 to your computer and use it in GitHub Desktop.
Save alertor/29839500922a75cb2b61 to your computer and use it in GitHub Desktop.
get zodiacal sign by DD-MM
# from http://stackoverflow.com/questions/3274597/how-would-i-determine-zodiac-astrological-star-sign-from-a-birthday-in-python
from bisect import bisect
signs = [(1,20,"Cap"), (2,18,"Aqu"), (3,20,"Pis"), (4,20,"Ari"),
(5,21,"Tau"), (6,21,"Gem"), (7,22,"Can"), (8,23,"Leo"),
(9,23,"Vir"), (10,23,"Lib"), (11,22,"Sco"), (12,22,"Sag"),
(12,31,"Cap")]
def zodiac_sign(m,d):
return signs[bisect(signs,(m,d))][2]
assert zodiac_sign(3,9) == "Pis"
assert zodiac_sign(6,30) == "Can"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment