Решение на Хороскоп от Георги Урумов

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

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

Резултати

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

Код

def what_is_my_sign(day, month):
signs = {1:'Овен', 2:'Телец', 3:'Близнаци', 4:'Рак',
5:'Лъв', 6:'Дева', 7:'Везни', 8:'Скорпион',
9:'Стрелец', 10:'Козирог', 11:'Водолей', 12:'Риби'}
if month == 3 and day >= 21 or month == 4 and day <= 20:
sign = 1
elif month == 4 and day >= 21 or month == 5 and day <= 20:
sign = 2
elif month == 5 and day >= 21 or month == 6 and day <= 20:
sign = 3
elif month == 6 and day >= 21 or month == 7 and day <= 21:
sign = 4
elif month == 7 and day >= 22 or month == 8 and day <= 22:
sign = 5
elif month == 8 and day >= 23 or month == 9 and day <= 22:
sign = 6
elif month == 9 and day >= 23 or month == 10 and day <= 22:
sign = 7
elif month == 10 and day >= 23 or month == 11 and day <= 21:
sign = 8
elif month == 11 and day >= 22 or month == 12 and day <= 21:
sign = 9
elif month == 12 and day >= 22 or month == 1 and day <= 19:
sign = 10
elif month == 1 and day >= 20 or month == 2 and day <= 18:
sign = 11
elif month == 2 and day >= 19 or month == 3 and day <= 20:
sign = 12
return signs.get(sign)

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

...............
----------------------------------------------------------------------
Ran 15 tests in 0.001s

OK

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

Георги обнови решението на 04.03.2013 01:15 (преди почти 12 години)

+def what_is_my_sign(day, month):
+
+ signs = {1:'Овен', 2:'Телец', 3:'Близнаци', 4:'Рак',
+ 5:'Лъв', 6:'Дева', 7:'Везни', 8:'Скорпион',
+ 9:'Стрелец', 10:'Козирог', 11:'Водолей', 12:'Риби'}
+
+ if month == 3 and day >= 21 or month == 4 and day <= 20:
+ sign = 1
+ elif month == 4 and day >= 21 or month == 5 and day <= 20:
+ sign = 2
+ elif month == 5 and day >= 21 or month == 6 and day <= 20:
+ sign = 3
+ elif month == 6 and day >= 21 or month == 7 and day <= 21:
+ sign = 4
+ elif month == 7 and day >= 22 or month == 8 and day <= 22:
+ sign = 5
+ elif month == 8 and day >= 23 or month == 9 and day <= 22:
+ sign = 6
+ elif month == 9 and day >= 23 or month == 10 and day <= 22:
+ sign = 7
+ elif month == 10 and day >= 23 or month == 11 and day <= 21:
+ sign = 8
+ elif month == 11 and day >= 22 or month == 12 and day <= 21:
+ sign = 9
+ elif month == 12 and day >= 22 or month == 1 and day <= 19:
+ sign = 10
+ elif month == 1 and day >= 20 or month == 2 and day <= 18:
+ sign = 11
+ elif month == 2 and day >= 19 or month == 3 and day <= 20:
+ sign = 12
+
+ return signs.get(sign)