Виктор обнови решението на 10.03.2015 23:02 (преди над 9 години)
+def interpret_western_sign(day, month):
+ if (20 < day <= 31 and month == 3) or (0 < day <= 20 and month == 4):
+ return "aries"
+ elif (20 < day <= 30 and month == 4) or (0 < day <= 20 and month == 5):
+ return "taurus"
+ elif (20 < day <= 31 and month == 5) or (0 < day <= 20 and month == 6):
+ return "gemini"
+ elif (20 < day <= 30 and month == 6) or (0 < day <= 22 and month == 7):
+ return "cancer"
+ elif (22 < day <= 31 and month == 7) or (0 < day <= 22 and month == 8):
+ return "leo"
+ elif (22 < day <= 31 and month == 8) or (0 < day <= 22 and month == 9):
+ return "virgo"
+ elif (22 < day <= 30 and month == 9) or (0 < day <= 22 and month == 10):
+ return "libra"
+ elif (22 < day <= 31 and month == 10) or (0 < day <= 21 and month == 11):
+ return "scorpio"
+ elif (21 < day <= 30 and month == 11) or (0 < day <= 21 and month == 12):
+ return "sagittarius"
+ elif (21 < day <= 31 and month == 12) or (0 < day <= 20 and month == 1):
+ return "capricorn"
+ elif (20 < day <= 31 and month == 1) or (0 < day <= 19 and month == 2):
+ return "aquarius"
+ elif (19 < day <= 29 and month == 2) or (0 < day <= 20 and month == 3):
+ return "pisces"
+
+
+def interpret_chinese_sign(year):
+ signs = {0: "rat", 1: "ox", 2: "tiger", 3: "rabbit", 4: "dragon",
+ 5: "snake", 6: "horse", 7: "sheep", 8: "monkey",
+ 9: "rooster", 10: "dog", 11: "pig"}
+ return signs[(year - 1900) % 12]
+
+
+def interpret_both_signs(day, month, year):
+ return interpret_western_sign(day, month), interpret_chinese_sign(year)
- В момента, в който еднаквите
if
-ове станаха повече от 5 не ти ли хрумна, че правиш нещо грешно? - Помисли коя колекция е по-добра идея да се използва в
interpret_chinese_sign
от речник :)