Михаил обнови решението на 07.03.2015 20:26 (преди над 9 години)
+def is_date_in_period(date_day, date_month, period):
+ if date_month == period[1]:
+ return date_day >= period[0]
+ elif date_month == period[3]:
+ return date_day <= period[2]
+ return False
+
+
+def interpret_western_sign(day, month):
+ calendar = {
+ (21, 3, 20, 4): 'aries',
+ (21, 4, 20, 5): 'taurus',
+ (21, 5, 20, 6): 'gemini',
+ (21, 6, 22, 7): 'cancer',
+ (23, 7, 22, 8): 'leo',
+ (23, 8, 22, 9): 'virgo',
+ (23, 9, 22, 10): 'libra',
+ (23, 10, 21, 11): 'scorpio',
+ (22, 11, 21, 12): 'sagittarius',
+ (22, 12, 20, 1): 'capricorn',
+ (21, 1, 18, 2): 'aquarius',
+ (19, 2, 20, 3): 'pisces',
+ }
+
+ for key in calendar:
+ if is_date_in_period(day, month, key):
+ return calendar[key]
+
+
+def interpret_chinese_sign(year):
+ calendar = [
+ 'rat',
+ 'ox',
+ 'tiger',
+ 'rabbit',
+ 'dragon',
+ 'snake',
+ 'horse',
+ 'sheep',
+ 'monkey',
+ 'rooster',
+ 'dog',
+ 'pig']
+ return calendar[(year - 4) % 12]
+
+
+def interpret_both_signs(day, month, year):
+ return (interpret_western_sign(day, month), interpret_chinese_sign(year))