Мариян обнови решението на 07.03.2015 18:57 (преди над 9 години)
+def interpret_western_sign(day, month):
+ month_signs = {
+ 1: ('capricorn', 'aquarius'),
+ 2: ('aquarius', 'pisces'),
+ 3: ('pisces', 'aries'),
+ 4: ('aries', 'taurus'),
+ 5: ('taurus', 'gemini'),
+ 6: ('gemini', 'cancer'),
+ 7: ('cancer', 'leo'),
+ 8: ('leo', 'virgo'),
+ 9: ('virgo', 'libra'),
+ 10: ('libra', 'scorpio'),
+ 11: ('scorpio', 'sagittarius'),
+ 12: ('sagittarius', 'capricorn')
+ }
+ my_signs = month_signs.get(month)
+ start_date_signs = {'capricorn': 22,
+ 'aquarius': 21,
+ 'pisces': 19,
+ 'aries': 21,
+ 'taurus': 21,
+ 'gemini': 21,
+ 'cancer': 21,
+ 'leo': 23,
+ 'virgo': 23,
+ 'libra': 23,
+ 'scorpio': 23,
+ 'sagittarius': 22
+ }
+ sign_date = start_date_signs.get(my_signs[1])
+ if sign_date > day:
+ return my_signs[0]
+ else:
+ return my_signs[1]
+
+
+def interpret_chinese_sign(year):
+ signs_indexes = {1: 'rat',
+ 2: 'ox',
+ 3: 'tiger',
+ 4: 'rabbit',
+ 5: 'dragon',
+ 6: 'snake',
+ 7: 'horse',
+ 8: 'sheep',
+ 9: 'monkey',
+ 10: 'rooster',
+ 11: 'dog',
+ 12: 'pig'
+ }
+ start_year = 1900
+ substraction = year - start_year
+ return signs_indexes.get((substraction % 12) + 1)
+
+
+def interpret_both_signs(day, month, year):
+ western_sign = interpret_western_sign(day, month)
+ chinese_sign = interpret_chinese_sign(year)
+ return (western_sign, chinese_sign)