Цветелина обнови решението на 09.03.2015 11:35 (преди над 9 години)
+#return string for western sign
+def interpret_western_sign(day, month):
+ zodiacs = ['aries', 'taurus', 'gemini',
+ 'cancer', 'leo', 'virgo',
+ 'libra', 'scorpio', 'sagittarius',
+ 'capricorn', 'aquarius', 'pisces'
+ ]
+ if month < 1 or month > 12:
+ return 'Invalid month argument value'
+ if day < 1 or day > 31:
+ return 'Invalid day argument value'
+ for i in range(1, 13):
+ turn_day = 20
+ decrem = i - 4
+ if month == i:
+ if month < 4:
+ decrem = i + 8
+ if month == 2:
+ turn_day = 18
+ if month > 6:
+ turn_day = 22
+ if month > 10:
+ turn_day = 21
+ if day <= turn_day:
+ return zodiacs[decrem]
+ else:
+ if decrem == 11:
+ return zodiacs[0]
+ else:
+ return zodiacs[decrem + 1]
+#return string for chinese sign
+def interpret_chinese_sign(year):
+ zodiacs = ['monkey', 'rooster', 'dog',
+ 'pig', 'rat', 'ox', 'tiger',
+ 'rabbit', 'dragon', 'snake',
+ 'horse', 'sheep',
+ ]
+ for i in range(0, 12):
+ if year % 12 == i:
+ return zodiacs[i]
+#return tuple of 2 strings for both signs
+def interpret_both_signs(day, month, year):
+ western = interpret_western_sign(day, month)
+ chinese = interpret_chinese_sign(year)
+ return (western, chinese)