Михаела обнови решението на 10.03.2015 23:31 (преди над 9 години)
+def interpret_western_sign(day, month):
+ if month == 1:
+ if day <= 20:
+ return 'capricorn'
+ else:
+ return 'aquarius'
+ elif month == 2:
+ if day <= 18:
+ return 'aquarius'
+ else:
+ return 'pisces'
+ elif month == 3:
+ if day <= 20:
+ return 'pisces'
+ else:
+ return 'aries'
+ elif month == 4:
+ if day <= 20:
+ return 'aries'
+ else:
+ return 'taurus'
+ elif month == 5:
+ if day <= 20:
+ return 'taurus'
+ else:
+ return 'gemini'
+ elif month == 6:
+ if day <= 20:
+ return 'gemini'
+ else:
+ return 'cancer'
+ elif month == 7:
+ if day <= 22:
+ return 'cancer'
+ else:
+ return 'leo'
+ elif month == 8:
+ if day <= 22:
+ return 'leo'
+ else:
+ return 'virgo'
+ elif month == 9:
+ if day <= 22:
+ return 'virgo'
+ else:
+ return 'libra'
+ elif month == 10:
+ if day <= 22:
+ return 'libra'
+ else:
+ return 'scorpio'
+ elif month == 11:
+ if day <= 21:
+ return 'scorpio'
+ else:
+ return 'sagittarius'
+ elif month == 12:
+ if day <= 21:
+ return 'sagittarius'
+ else:
+ return 'capricorn'
+
+
+def interpret_chinese_sign(year):
+ if year % 12 == 1:
+ return "rooster"
+ elif year % 12 == 2:
+ return "dog"
+ elif year % 12 == 3:
+ return "pig"
+ elif year % 12 == 4:
+ return "rat"
+ elif year % 12 == 5:
+ return "ox"
+ elif year % 12 == 6:
+ return "tiger"
+ elif year % 12 == 7:
+ return "rabbit"
+ elif year % 12 == 8:
+ return "dragon"
+ elif year % 12 == 9:
+ return "snake"
+ elif year % 12 == 10:
+ return "horse"
+ elif year % 12 == 11:
+ return "sheep"
+ elif year % 12 == 0:
+ return "monkey"
+
+
+def interpret_both_signs(day, month, year):
+ return (interpret_western_sign(day, month), interpret_chinese_sign(year))
Опитай се да опростиш малко. Имаш решение на повече от 90 реда if-ове за всичко на всичко 24 зодии. Ами ако бяха 500?