Галин обнови решението на 05.03.2015 13:05 (преди над 9 години)
+def interpret_western_sign(day, month):
+ m = month
+ if m == 3 and day in range(21, 32) or m == 4 and day in range(1, 21):
+ return "aries"
+ if m == 4 and day in range(21, 31) or m == 5 and day in range(1, 22):
+ return "taurus"
+ if m == 5 and day in range(22, 32) or m == 6 and day in range(1, 22):
+ return "gemini"
+ if m == 6 and day in range(22, 31) or m == 7 and day in range(1, 23):
+ return "cancer"
+ if m == 7 and day in range(23, 32) or m == 8 and day in range(1, 23):
+ return "leo"
+ if m == 8 and day in range(23, 32) or m == 9 and day in range(1, 24):
+ return "virgo"
+ if m == 9 and day in range(24, 31) or m == 10 and day in range(1, 24):
+ return "libra"
+ if m == 10 and day in range(24, 32) or m == 11 and day in range(1, 23):
+ return "scorpio"
+ if m == 11 and day in range(23, 31) or m == 12 and day in range(1, 22):
+ return "sagittarius"
+ if m == 12 and day in range(22, 32) or m == 1 and day in range(1, 21):
+ return "capricorn"
+ if m == 1 and day in range(21, 32) or m == 2 and day in range(1, 20):
+ return "aquarius"
+ if m == 2 and day in range(20, 29) or m == 3 and day in range(1, 21):
+ return "pisces"
+
+
+def interpret_chinese_sign(year):
+ if (year - 1900) % 12 == 0:
+ return "rat"
+ if (year - 1900) % 12 == 1:
+ return "ox"
+ if (year - 1900) % 12 == 2:
+ return "tiger"
+ if (year - 1900) % 12 == 3:
+ return "rabbit"
+ if (year - 1900) % 12 == 4:
+ return "dragon"
+ if (year - 1900) % 12 == 5:
+ return "snake"
+ if (year - 1900) % 12 == 6:
+ return "horse"
+ if (year - 1900) % 12 == 7:
+ return "sheep"
+ if (year - 1900) % 12 == 8:
+ return "monkey"
+ if (year - 1900) % 12 == 9:
+ return "rooster"
+ if (year - 1900) % 12 == 10:
+ return "dog"
+ if (year - 1900) % 12 == 11:
+ return "pig"
+
+
+def interpret_both_signs(day, month, year):
+ return (interpret_western_sign(day, month), interpret_chinese_sign(year))
Сега си представи, че зодиите бяха 3624 на брой. Пак ли щеше да имаш отделен if
за всеки случай? Опитай се да опростиш малко :)