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

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

Към профила на Виктор Цонев

Резултати

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

Код

def interpret_western_sign(day, month):
if (20 < day <= 31 and month == 3) or (0 < day <= 20 and month == 4):
return "aries"
elif (20 < day <= 30 and month == 4) or (0 < day <= 20 and month == 5):
return "taurus"
elif (20 < day <= 31 and month == 5) or (0 < day <= 20 and month == 6):
return "gemini"
elif (20 < day <= 30 and month == 6) or (0 < day <= 22 and month == 7):
return "cancer"
elif (22 < day <= 31 and month == 7) or (0 < day <= 22 and month == 8):
return "leo"
elif (22 < day <= 31 and month == 8) or (0 < day <= 22 and month == 9):
return "virgo"
elif (22 < day <= 30 and month == 9) or (0 < day <= 22 and month == 10):
return "libra"
elif (22 < day <= 31 and month == 10) or (0 < day <= 21 and month == 11):
return "scorpio"
elif (21 < day <= 30 and month == 11) or (0 < day <= 21 and month == 12):
return "sagittarius"
elif (21 < day <= 31 and month == 12) or (0 < day <= 20 and month == 1):
return "capricorn"
elif (20 < day <= 31 and month == 1) or (0 < day <= 19 and month == 2):
return "aquarius"
elif (19 < day <= 29 and month == 2) or (0 < day <= 20 and month == 3):
return "pisces"
def interpret_chinese_sign(year):
signs = ["rat", "ox", "tiger", "rabbit", "dragon",
"snake", "horse", "sheep", "monkey",
"rooster", "dog", "pig"]
return signs[(year - 1900) % 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

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

Виктор обнови решението на 10.03.2015 23:02 (преди над 9 години)

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

Виктор обнови решението на 11.03.2015 11:19 (преди над 9 години)

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