Мартин обнови решението на 10.03.2015 22:04 (преди над 9 години)
+def interpret_western_sign(day, month):
+ if day <= 0 or day > 31 or month <= 0 or month > 12:
+ return 'invalid date'
+ else:
+ all_signs = [ ('aries', 3, 21, 31, 4, 20),
+ ('taurus', 4, 21, 30, 5, 20),
+ ('gemini', 5, 21, 31, 6, 20),
+ ('cancer', 6, 21, 30, 7, 22),
+ ('leo', 7, 23, 31, 8, 22),
+ ('virgo', 8, 23, 31, 9, 22),
+ ('libra', 9, 23, 30, 10, 22),
+ ('scorpio', 10, 23, 31, 11, 21),
+ ('sagittarius', 11, 22, 30, 12, 21),
+ ('capricorn', 12, 22, 31, 1, 20),
+ ('aquarius', 1, 21, 31, 2, 19),
+ ('pisces', 2, 19, 29, 3, 20) ]
+
+ for el in all_signs:
+ if (month == el[1] and day >= el[2] and day <= el[3]) or \
+ (month == el[4] and day <= el[5]):
+ return el[0]
+
+def interpret_chinese_sign(year):
+ x = (year + 8) % 12
+ all_signs = ['rat' , 'ox' , 'tiger' , 'rabbit' , 'dragon' ,
+ 'snake' , 'horse' , 'sheep' , 'monkey' , 'rooster' ,
+ 'dog' , 'pig']
+
+ return all_signs[x]
+
+def interpret_both_signs(day, month, year):
+ by_year = interpret_chinese_sign(year)
+ by_month_day = interpret_western_sign(day , month)
+ return (by_month_day , by_year)