Владимир обнови решението на 11.03.2015 13:04 (преди над 9 години)
+western_signs = {
+ (3, 21, 4, 20): 'aries', (4, 21, 5, 20): 'tautus',
+ (5, 21, 6, 20): 'gemini', (6, 21, 7, 22): 'cancer',
+ (7, 23, 8, 22): 'leo', (8, 23, 9, 22): 'virgo',
+ (9, 23, 10, 22): 'libra', (10, 23, 11, 21): 'scorpio',
+ (11, 22, 12, 21): 'sagittarius', (12, 22, 1, 20): 'capricorn',
+ (1, 21, 2, 19): 'aquarius', (2, 19, 3, 20): 'pisces'
+}
+
+
+def interpret_western_sign(day, month):
+
+ for sign in western_signs.items():
+ start_month = sign[0][0]
+ start_day = sign[0][1]
+ end_month = sign[0][2]
+ end_day = sign[0][3]
+
+ if day >= start_day and month == start_month or \
+ day <= end_day and month == end_month:
+ return sign[1]
+
+chinese_signs = {
+ 1900: 'rat',
+ 1901: 'ox',
+ 1902: 'tiger',
+ 1903: 'rabbit',
+ 1904: 'dragon',
+ 1905: 'snake',
+ 1906: 'horse',
+ 1907: 'sheep',
+ 1908: 'monkey',
+ 1909: 'rooster',
+ 1910: 'dog',
+ 1911: 'pig'
+ }
+
+
+def interpret_chinese_sign(year):
+
+ zodiac = 1900 + ((year - 1900) % 12)
+ return chinese_signs[zodiac]
+
+
+def interpret_both_signs(day, month, year):
+
+ zodiac_western = interpret_western_sign(day, month)
+ zodiac_chinese = interpret_chinese_sign(year)
+
+ return zodiac_western, zodiac_chinese,
- Имената на константите трябва да са в
SCREAMING_SNAKE_CASE
- Не е нужно да слагаш толкова празни редове в тялото на функциите
Благодаря