Решение на Астрологични забави от Георги Чулев

Обратно към всички решения

Към профила на Георги Чулев

Резултати

  • 10 точки от тестове
  • 0 бонус точки
  • 10 точки общо
  • 6 успешни тест(а)
  • 0 неуспешни тест(а)

Код

WESTERN_SIGNS = [(22, 'capricorn'),
(21, 'aquarius'),
(19, 'pisces'),
(21, 'aries'),
(21, 'taurus'),
(21, 'gemini'),
(21, 'cancer'),
(23, 'leo'),
(23, 'virgo'),
(23, 'libra'),
(23, 'scorpio'),
(22, 'sagittarius'),
(22, 'capricorn')
]
CHINESE_SIGNS = ['rat', 'ox', 'tiger', 'rabbit', 'dragon',
'snake', 'horse', 'sheep', 'monkey',
'rooster', 'dog', 'pig'
]
def interpret_western_sign(day, month):
""" Returns the zodiac sign, according to the Western Zodiac. """
if day >= WESTERN_SIGNS[month][0]:
return WESTERN_SIGNS[month][1]
else:
return WESTERN_SIGNS[month - 1][1]
def interpret_chinese_sign(year):
""" Returns the zodiac sign, according to the Chinese Zodiac. """
year_offset = year - 1900
return CHINESE_SIGNS[year_offset % 12]
def interpret_both_signs(day, month, year):
""" Returns the Western and Chinese zodiacs of a person. """
western_sign = interpret_western_sign(day, month)
chinese_sign = interpret_chinese_sign(year)
return (western_sign, chinese_sign)

Лог от изпълнението

......
----------------------------------------------------------------------
Ran 6 tests in 0.008s

OK

История (2 версии и 0 коментара)

Георги обнови решението на 06.03.2015 11:27 (преди над 9 години)

+WESTERN_SIGNS = [(22, 'capricorn'),
+ (21, 'aquarius'),
+ (19, 'pisces'),
+ (21, 'aries'),
+ (21, 'taurus'),
+ (21, 'gemini'),
+ (21, 'cancer'),
+ (23, 'leo'),
+ (23, 'virgo'),
+ (23, 'libra'),
+ (23, 'scorpio'),
+ (22, 'sagittarius'),
+ (22, 'capricorn')
+ ]
+
+CHINESE_SIGNS = ['rat', 'ox', 'tiger', 'rabbit', 'dragon',
+ 'snake', 'horse', 'sheep', 'monkey',
+ 'rooster', 'dog', 'pig'
+ ]
+
+
+def interpret_western_sign(day, month):
+ """ Returns the zodiac sign, according to the Western Zodiac. """
+ if day >= WESTERN_SIGNS[month][0]:
+ return WESTERN_SIGNS[month][1]
+ else:
+ return WESTERN_SIGNS[month - 1][1]
+
+
+def interpret_chinese_sign(year):
+ """ Returns the zodiac sign, according to the Chinese Zodiac. """
+ year_offset = year - 1900
+
+ return CHINESE_SIGNS[year_offset % 12]
+
+
+def interpret_both_signs(day, month, year):
+ """ Returns the Western and Chinese zodiacs of a person. """
+ western_sign = interpret_western_sign(day, month)
+ chinese_sign = interpret_chinese_sign(year)
+
+ return (western_sign, chinese_sign)

Георги обнови решението на 09.03.2015 13:04 (преди над 9 години)

WESTERN_SIGNS = [(22, 'capricorn'),
(21, 'aquarius'),
(19, 'pisces'),
(21, 'aries'),
(21, 'taurus'),
(21, 'gemini'),
(21, 'cancer'),
(23, 'leo'),
(23, 'virgo'),
(23, 'libra'),
(23, 'scorpio'),
(22, 'sagittarius'),
(22, 'capricorn')
]
CHINESE_SIGNS = ['rat', 'ox', 'tiger', 'rabbit', 'dragon',
'snake', 'horse', 'sheep', 'monkey',
'rooster', 'dog', 'pig'
]
def interpret_western_sign(day, month):
""" Returns the zodiac sign, according to the Western Zodiac. """
if day >= WESTERN_SIGNS[month][0]:
return WESTERN_SIGNS[month][1]
else:
return WESTERN_SIGNS[month - 1][1]
def interpret_chinese_sign(year):
""" Returns the zodiac sign, according to the Chinese Zodiac. """
year_offset = year - 1900
return CHINESE_SIGNS[year_offset % 12]
def interpret_both_signs(day, month, year):
""" Returns the Western and Chinese zodiacs of a person. """
western_sign = interpret_western_sign(day, month)
chinese_sign = interpret_chinese_sign(year)
- return (western_sign, chinese_sign)
+ return (western_sign, chinese_sign)