Решение на Хороскоп от Добринка Табакова

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

Към профила на Добринка Табакова

Резултати

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

Код

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

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

...............
----------------------------------------------------------------------
Ran 15 tests in 0.002s

OK

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

Добринка обнови решението на 03.03.2013 23:48 (преди над 11 години)

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

Добринка обнови решението на 04.03.2013 00:15 (преди над 11 години)

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

Добринка обнови решението на 04.03.2013 10:47 (преди над 11 години)

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