Александър обнови решението на 10.03.2015 10:17 (преди над 9 години)
+starsigns = {
+ 'aries': ((21, 3), (20, 4)),
+ 'taurus': ((21, 4), (20, 5)),
+ 'gemini': ((21, 5), (20, 6)),
+ 'cancer': ((21, 6), (22, 7)),
+ 'leo': ((23, 7), (22, 8)),
+ 'virgo': ((23, 8), (22, 9)),
+ 'libra': ((23, 9), (22, 10)),
+ 'scorpio': ((23, 10), (21, 11)),
+ 'sagittarius': ((22, 11), (21, 12)),
+ 'capricorn': ((22, 12), (20, 1)),
+ 'aquarius': ((21, 1), (19, 2)),
+ 'pisces': ((19, 2), (20, 3))
+}
+
+chinese_signs_initial_years = {
+ 'rat': 1900,
+ 'ox': 1901,
+ 'tiger': 1902,
+ 'rabbit': 1903,
+ 'dragon': 1904,
+ 'snake': 1905,
+ 'horse': 1906,
+ 'sheep': 1907,
+ 'monkey': 1908,
+ 'rooster': 1909,
+ 'dog': 1910,
+ 'pig': 1911
+}
+
+def interpret_western_sign(day, month):
+ for sign, sign_interval in starsigns.items():
+ if ((sign_interval[0][1] == month and sign_interval[0][0] <= day) or
+ (sign_interval[1][1] == month and sign_interval[1][0] >= day)):
+ return sign
+
+def interpret_chinese_sign(year):
+ for sign, sign_initial_year in chinese_signs_initial_years.items():
+ if (year - sign_initial_year) % 12 == 0:
+ return sign
+
+def interpret_both_signs(day, month, year):
+ return (interpret_western_sign(day, month), interpret_chinese_sign(year))
+
- дай константите в
SCREAM_SNAKE_CASE
- отделяй глобално дефинираните функции с 2 празни реда
- имаш някакви интервали в края на ред 17
и си bombastic