Решение на Астрологични забави от Деница Петрова

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

Към профила на Деница Петрова

Резултати

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

Код

WESTERN_SIGNS = {"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), (18, 2)),
"pisces": ((19, 2), (20, 3))}
def interpret_western_sign(day, month):
for sign, duration in WESTERN_SIGNS.items():
start_day = duration[0][0]
end_day = duration[1][0]
start_month = duration[0][1]
end_month = duration[1][1]
if day >= start_day and month == start_month:
return sign
if day <= end_day and month == end_month:
return sign
CHINESE_SIGNS = ["rat", "ox", "tiger", "rabbit", "dragon", "snake",
"horse", "sheep", "monkey", "rooster", "dog", "pig"]
def interpret_chinese_sign(year):
return CHINESE_SIGNS[((year - 4) % 12)]
def interpret_both_signs(day, month, year):
return(interpret_western_sign(day, month), interpret_chinese_sign(year))

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

......
----------------------------------------------------------------------
Ran 6 tests in 0.006s

OK

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

Деница обнови решението на 07.03.2015 17:51 (преди над 9 години)

+WESTERN_SIGNS = {"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), (18, 2)),
+ "pisces": ((19, 2), (20, 3))}
+
+def interpret_western_sign(day, month):
+ for sign, duration in WESTERN_SIGNS.items():
+ start_day = duration[0][0]
+ end_day = duration[1][0]
+ start_month = duration[0][1]
+ end_month = duration[1][1]
+ if day >= start_day and month == start_month:
+ return sign
+ if day <= end_day and month == end_month:
+ return sign
+
+
+CHINESE_SIGNS = ["rat", "ox", "tiger", "rabbit", "dragon", "snake",
+ "horse", "sheep", "monkey", "rooster", "dog", "pig"]
+
+def interpret_chinese_sign(year):
+ return CHINESE_SIGNS[((year - 4) % 12)]
+
+def interpret_both_signs(day, month, year):
+ return(interpret_western_sign(day, month), interpret_chinese_sign(year))