Решение на Астрологични забави от Никола Костов

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

Към профила на Никола Костов

Резултати

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

Код

def interpret_western_sign(day, month):
if (month == 3 and day >= 21) or (month == 4 and day <= 20):
return 'aries'
if (month == 4 and day >= 21) or (month == 5 and day <= 20):
return 'taurus'
if (month == 5 and day >= 21) or (month == 6 and day <= 20):
return 'gemini'
if (month == 6 and day >= 21) or (month == 7 and day <= 22):
return 'cancer'
if (month == 7 and day >= 23) or (month == 8 and day <= 22):
return 'leo'
if (month == 8 and day >= 23) or (month == 9 and day <= 22):
return 'virgo'
if (month == 9 and day >= 23) or (month == 10 and day <= 22):
return 'libra'
if (month == 10 and day >= 23) or (month == 11 and day <= 21):
return 'scorpio'
if (month == 11 and day >= 22) or (month == 12 and day <= 21):
return 'sagittarius'
if (month == 12 and day >= 22) or (month == 1 and day <= 20):
return 'capricorn'
if (month == 1 and day >= 21) or (month == 2 and day <= 19):
return 'aquarius'
if (month == 2 and day >= 20) or (month == 3 and day <= 20):
return 'pisces'
def interpret_chinese_sign(year):
start_year = 1900
chinese_signs = ['rat', 'ox', 'tiger', 'rabbit', 'dragon', 'snake',
'horse', 'sheep', 'monkey', 'rooster', 'dog', 'pig']
return chinese_signs[(year - start_year) % 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 версия и 1 коментар)

Никола обнови решението на 09.03.2015 23:07 (преди над 9 години)

+def interpret_western_sign(day, month):
+ if (month == 3 and day >= 21) or (month == 4 and day <= 20):
+ return 'aries'
+ if (month == 4 and day >= 21) or (month == 5 and day <= 20):
+ return 'taurus'
+ if (month == 5 and day >= 21) or (month == 6 and day <= 20):
+ return 'gemini'
+ if (month == 6 and day >= 21) or (month == 7 and day <= 22):
+ return 'cancer'
+ if (month == 7 and day >= 23) or (month == 8 and day <= 22):
+ return 'leo'
+ if (month == 8 and day >= 23) or (month == 9 and day <= 22):
+ return 'virgo'
+ if (month == 9 and day >= 23) or (month == 10 and day <= 22):
+ return 'libra'
+ if (month == 10 and day >= 23) or (month == 11 and day <= 21):
+ return 'scorpio'
+ if (month == 11 and day >= 22) or (month == 12 and day <= 21):
+ return 'sagittarius'
+ if (month == 12 and day >= 22) or (month == 1 and day <= 20):
+ return 'capricorn'
+ if (month == 1 and day >= 21) or (month == 2 and day <= 19):
+ return 'aquarius'
+ if (month == 2 and day >= 20) or (month == 3 and day <= 20):
+ return 'pisces'
+
+
+def interpret_chinese_sign(year):
+ start_year = 1900
+ chinese_signs = ['rat', 'ox', 'tiger', 'rabbit', 'dragon', 'snake',
+ 'horse', 'sheep', 'monkey', 'rooster', 'dog', 'pig']
+ return chinese_signs[(year - start_year) % 12]
+
+
+def interpret_both_signs(day, month, year):
+ return (interpret_western_sign(day, month), interpret_chinese_sign(year))