Христиан обнови решението на 08.03.2015 12:13 (преди над 9 години)
+def interpret_chinese_sign(year):
+ new_year = year - 1900
+ sign_num = new_year % 12
+ if sign_num is 0:
+ return "rat"
+ elif sign_num is 1:
+ return "ox"
+ elif sign_num is 2:
+ return "tiger"
+ elif sign_num is 3:
+ return "rabbit"
+ elif sign_num is 4:
+ return "dragon"
+ elif sign_num is 5:
+ return "snake"
+ elif sign_num is 6:
+ return "horse"
+ elif sign_num is 7:
+ return "sheep"
+ elif sign_num is 8:
+ return "monkey"
+ elif sign_num is 9:
+ return "rooster"
+ elif sign_num is 10:
+ return "dog"
+ elif sign_num is 11:
+ return "pig"
+
+
+def interpret_western_sign(day, month):
+ if month is 3 and day >= 21 or \
+ month is 4 and day <= 20:
+ return "aries"
+ elif month is 4 and day >= 21 or \
+ month is 5 and day <= 20:
+ return "taurus"
+ elif month is 5 and day >= 21 or \
+ month is 6 and day <= 20:
+ return "gemini"
+ elif month is 6 and day >= 21 or \
+ month is 7 and day <= 22:
+ return "cancer"
+ elif month is 7 and day >= 23 or \
+ month is 8 and day <= 22:
+ return "leo"
+ elif month is 8 and day >= 23 or \
+ month is 9 and day <= 22:
+ return "virgo"
+ elif month is 9 and day >= 23 or \
+ month is 10 and day <= 22:
+ return "libra"
+ elif month is 10 and day >= 23 or \
+ month is 11 and day <= 21:
+ return "scorpio"
+ elif month is 11 and day >= 22 or \
+ month is 12 and day <= 21:
+ return "sagittarius"
+ elif month is 12 and day >= 22 or \
+ month is 1 and day <= 20:
+ return "capricorn"
+ elif month is 1 and day >= 21 or \
+ month is 2 and day <= 18:
+ return "aquarius"
+ elif month is 2 and day >= 19 or \
+ month is 3 and day <= 20:
+ return "pisces"
+
+
+def interpret_both_signs(day, month, year):
+ western_sign = interpret_western_sign(day, month)
+ chinese_sign = interpret_chinese_sign(year)
+ return (western_sign, chinese_sign)
Добре.. зодиите са само 12. Ако бяха 13 пак ли щеше да пишеш отделен if
else
за всяка? Ами ако бяха 1300? Пробвай се да генерализираш, ползвайки някоя структура от данни например. Прегледай първата лецкия за идеи.