Дарко обнови решението на 11.03.2015 15:23 (преди над 9 години)
+western_signs = ('aries', 'taurus', 'gemini', 'cancer', 'leo', 'virgo',
+ 'libra', 'scorpio', 'sagittarius', 'capricorn',
+ 'aquarius', 'pisces')
+chinese_signs = ('rat', 'ox', 'tiger', 'rabbit', 'dragon', 'snake', 'horse',
+ 'sheep', 'monkey', 'rooster', 'dog', 'pig')
+
+
+def interpret_western_sign(day, month):
+ if (month == 3 and day < 21) or (month == 2 and 18 < day < 30):
+ return western_signs[11]
+ elif (month == 4 and day < 21) or (month == 3 and 20 < day < 32):
+ return western_signs[0]
+ elif (month == 5 and day < 21) or (month == 4 and 20 < day < 31):
+ return western_signs[1]
+ elif (month == 6 and day < 21) or (month == 5 and 20 < day < 32):
+ return western_signs[2]
+ elif (month == 7 and day < 23) or (month == 6 and 20 < day < 31):
+ return western_signs[3]
+ elif (month == 8 and day < 23) or (month == 7 and 22 < day < 32):
+ return western_signs[4]
+ elif (month == 9 and day < 23) or (month == 8 and 22 < day < 32):
+ return western_signs[5]
+ elif (month == 10 and day < 23) or (month == 9 and 22 < day < 31):
+ return western_signs[6]
+ elif (month == 11 and day < 22) or (month == 10 and 22 < day < 32):
+ return western_signs[7]
+ elif (month == 12 and day < 22) or (month == 11 and 21 < day < 31):
+ return western_signs[8]
+ elif (month == 1 and day < 21) or (month == 12 and 21 < day < 32):
+ return western_signs[9]
+ elif (month == 2 and day < 19) or (month == 1 and 20 < day < 32):
+ return western_signs[10]
+
+
+def interpret_chinese_sign(year):
+ if year % 12 == 4:
+ return chinese_signs[0]
+ elif year % 12 == 5:
+ return chinese_signs[1]
+ elif year % 12 == 6:
+ return chinese_signs[2]
+ elif year % 12 == 7:
+ return chinese_signs[3]
+ elif year % 12 == 8:
+ return chinese_signs[4]
+ elif year % 12 == 9:
+ return chinese_signs[5]
+ elif year % 12 == 10:
+ return chinese_signs[6]
+ elif year % 12 == 11:
+ return chinese_signs[7]
+ elif year % 12 == 0:
+ return chinese_signs[8]
+ elif year % 12 == 1:
+ return chinese_signs[9]
+ elif year % 12 == 2:
+ return chinese_signs[10]
+ elif year % 12 == 3:
+ return chinese_signs[11]
+
+
+def interpret_both_signs(day, month, year):
+ return (interpret_western_sign(int(day), int(month)),
+ interpret_chinese_sign(int(year)))
- с тези
if
-ове ако имаше 102 зодии щеше да се побъркаш - времето, оставащо до крайния срок е малко, но имам някакво убеждение, че може да се досетиш как да премахнеш
if
-овете поне от функциятаinterpret_chinese_sign
- глобалните променливи се пишат в SCREAM_SNAKE_CASE
- няма нужда от това конвертиране към
int()
вinterpret_both_signs
(и даже ще ти се събере на един ред)