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

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

Към профила на Николина Тодорова

Резултати

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

Код

day = input("Enter a day: ")
month = input("Enter a month: ")
year = input("Enter a year:")
year = int(year)
def interpret_western_sign(day,month):
if (int(month) == 3 and int(day) <= 21) or (int(month) == 4 and int(day) <= 20):
return "aries"
elif (int(month) == 4 and int(day) <= 21) or (int(month) == 5 and int(day) <= 20):
return("taurus")
elif (int(month) == 5 and int(day) <= 21) or (int(month) == 6 and int(day) <= 20):
return("gemini")
elif (int(month) == 6 and int(day) <= 21) or (int(month) == 7 and int(day) <= 22):
return("cancer")
elif (int(month) == 7 and int(day) <= 23) or (int(month) == 8 and int(day) <= 22):
return("leo")
elif (int(month) == 8 and int(day) <= 23) or (int(month) == 9 and int(day) <= 22):
return("virgo")
elif (int(month) == 9 and int(day) <= 23) or (int(month) == 10 and int(day) <= 22):
return("libra")
elif (int(month) == 10 and int(day) <= 23) or (int(month) == 11 and int(day) <= 21):
return("scorpio")
elif (int(month) == 11 and int(day) <= 22) or (int(month) == 12 and int(day) <= 21):
return("sagittarius")
elif (int(month) == 12 and int(day) <= 22) or (int(month) == 1 and int(day) <= 20):
return("capricorn")
elif (int(month) == 1 and int(day) <= 21) or (int(month) == 2 and int(day) <= 19):
return("aquarius")
elif (int(month) == 2 and int(day) <= 19) or (int(month) == 3 and int(day) <= 20):
return("pisces")
def interpret_chinese_sign(year):
year = int(year)
if year % 12 == 0:
return ("monkey")
elif year % 12 == 1:
return ("rooster")
elif year % 12 == 2:
return ("dog")
elif year % 12 == 3:
return ("pig")
elif year % 12 == 4:
return ("rat")
elif year % 12 == 5:
return ("ox")
elif year % 12 == 6:
return ("tiger")
elif year % 12 == 7:
return ("rabbit")
elif year % 12 == 8:
return ("dragon")
elif year % 12 == 9:
return ("snake")
elif year % 12 == 10:
return ("horse")
else:
return ("sheep")
def interpret_both_signs(day, month, year):
x = (interpret_western_sign(day,month), interpret_chinese_sign(year))
return x
print (interpret_both_signs(day, month, year))

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

Enter a day: EOF when reading a line
  File "lib/language/python/runner.py", line 102, in main
    test = imp.load_source('test', test_module)
  File "/home/pyfmi/Python-3.4.2/Lib/imp.py", line 171, in load_source
    module = methods.load()
  File "<frozen importlib._bootstrap>", line 1220, in load
  File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1129, in _exec
  File "<frozen importlib._bootstrap>", line 1471, in exec_module
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "/tmp/d20150312-24164-1r49lgh/test.py", line 2, in <module>
    import solution
  File "/tmp/d20150312-24164-1r49lgh/solution.py", line 1, in <module>
    day = input("Enter a day: ")

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

Николина обнови решението на 11.03.2015 08:25 (преди над 9 години)

+year = input("Enter a year:")
+day = input("Enter a day: ")
+month = input("Enter a month: ")
+year = int(year)
+
+def interpret_western_sign(day,month):
+
+ if (int(month) == 3 and int(day) <= 21) or (int(month) == 4 and int(day) <= 20):
+ return "aries"
+ elif (int(month) == 4 and int(day) <= 21) or (int(month) == 5 and int(day) <= 20):
+ return("taurus")
+ elif (int(month) == 5 and int(day) <= 21) or (int(month) == 6 and int(day) <= 20):
+ return("gemini")
+ elif (int(month) == 6 and int(day) <= 21) or (int(month) == 7 and int(day) <= 22):
+ return("cancer")
+ elif (int(month) == 7 and int(day) <= 23) or (int(month) == 8 and int(day) <= 22):
+ return("leo")
+ elif (int(month) == 8 and int(day) <= 23) or (int(month) == 9 and int(day) <= 22):
+ return("virgo")
+ elif (int(month) == 9 and int(day) <= 23) or (int(month) == 10 and int(day) <= 22):
+ return("libra")
+ elif (int(month) == 10 and int(day) <= 23) or (int(month) == 11 and int(day) <= 21):
+ return("scorpio")
+ elif (int(month) == 11 and int(day) <= 22) or (int(month) == 12 and int(day) <= 21):
+ return("sagittarius")
+ elif (int(month) == 12 and int(day) <= 22) or (int(month) == 1 and int(day) <= 20):
+ return("capricorn")
+ elif (int(month) == 1 and int(day) <= 21) or (int(month) == 2 and int(day) <= 19):
+ return("aquarius")
+ elif (int(month) == 2 and int(day) <= 19) or (int(month) == 3 and int(day) <= 20):
+ return("pisces")
+
+
+def interpret_chinese_sign(year):
+ year = int(year)
+
+ if year % 12 == 0:
+ return ("monkey")
+
+ elif year % 12 == 1:
+ return ("rooster")
+
+ elif year % 12 == 2:
+ return ("fog")
+
+ elif year % 12 == 3:
+ return ("pig")
+
+ elif year % 12 == 4:
+ return ("rat")
+
+ elif year % 12 == 5:
+ return ("ox")
+
+ elif year % 12 == 6:
+ return ("tiger")
+
+ elif year % 12 == 7:
+ return ("rabbit")
+
+ elif year % 12 == 8:
+ return ("dragon")
+
+ elif year % 12 == 9:
+ return ("snake")
+
+ elif year % 12 == 10:
+ return ("horse")
+
+ else:
+ return ("sheep")
+
+def interpret_both_signs(day, month, year):
+ x = (interpret_western_sign(day,month), interpret_chinese_sign(year))
+
+ return x
+
+
+print (interpret_both_signs(day, month, year))
  • тестовете извикват функциите ви с различни аргумемти, а в твоя случай input-а чупи всичко, защото тестовете са автоматични иняма@ да се въвеждат данни от stdin
  • print-овете са напълно безполезни в решенията ви

Николина обнови решението на 11.03.2015 13:27 (преди над 9 години)

year = input("Enter a year:")
day = input("Enter a day: ")
month = input("Enter a month: ")
year = int(year)
def interpret_western_sign(day,month):
if (int(month) == 3 and int(day) <= 21) or (int(month) == 4 and int(day) <= 20):
return "aries"
elif (int(month) == 4 and int(day) <= 21) or (int(month) == 5 and int(day) <= 20):
return("taurus")
elif (int(month) == 5 and int(day) <= 21) or (int(month) == 6 and int(day) <= 20):
return("gemini")
elif (int(month) == 6 and int(day) <= 21) or (int(month) == 7 and int(day) <= 22):
return("cancer")
elif (int(month) == 7 and int(day) <= 23) or (int(month) == 8 and int(day) <= 22):
return("leo")
elif (int(month) == 8 and int(day) <= 23) or (int(month) == 9 and int(day) <= 22):
return("virgo")
elif (int(month) == 9 and int(day) <= 23) or (int(month) == 10 and int(day) <= 22):
return("libra")
elif (int(month) == 10 and int(day) <= 23) or (int(month) == 11 and int(day) <= 21):
return("scorpio")
elif (int(month) == 11 and int(day) <= 22) or (int(month) == 12 and int(day) <= 21):
return("sagittarius")
elif (int(month) == 12 and int(day) <= 22) or (int(month) == 1 and int(day) <= 20):
return("capricorn")
elif (int(month) == 1 and int(day) <= 21) or (int(month) == 2 and int(day) <= 19):
return("aquarius")
elif (int(month) == 2 and int(day) <= 19) or (int(month) == 3 and int(day) <= 20):
return("pisces")
def interpret_chinese_sign(year):
year = int(year)
if year % 12 == 0:
return ("monkey")
elif year % 12 == 1:
return ("rooster")
elif year % 12 == 2:
- return ("fog")
+ return ("dog")
elif year % 12 == 3:
return ("pig")
elif year % 12 == 4:
return ("rat")
elif year % 12 == 5:
return ("ox")
elif year % 12 == 6:
return ("tiger")
elif year % 12 == 7:
return ("rabbit")
elif year % 12 == 8:
return ("dragon")
elif year % 12 == 9:
return ("snake")
elif year % 12 == 10:
return ("horse")
else:
return ("sheep")
def interpret_both_signs(day, month, year):
x = (interpret_western_sign(day,month), interpret_chinese_sign(year))
return x
print (interpret_both_signs(day, month, year))

Николина обнови решението на 11.03.2015 13:34 (преди над 9 години)

-year = input("Enter a year:")
day = input("Enter a day: ")
month = input("Enter a month: ")
+year = input("Enter a year:")
year = int(year)
def interpret_western_sign(day,month):
if (int(month) == 3 and int(day) <= 21) or (int(month) == 4 and int(day) <= 20):
return "aries"
elif (int(month) == 4 and int(day) <= 21) or (int(month) == 5 and int(day) <= 20):
return("taurus")
elif (int(month) == 5 and int(day) <= 21) or (int(month) == 6 and int(day) <= 20):
return("gemini")
elif (int(month) == 6 and int(day) <= 21) or (int(month) == 7 and int(day) <= 22):
return("cancer")
elif (int(month) == 7 and int(day) <= 23) or (int(month) == 8 and int(day) <= 22):
return("leo")
elif (int(month) == 8 and int(day) <= 23) or (int(month) == 9 and int(day) <= 22):
return("virgo")
elif (int(month) == 9 and int(day) <= 23) or (int(month) == 10 and int(day) <= 22):
return("libra")
elif (int(month) == 10 and int(day) <= 23) or (int(month) == 11 and int(day) <= 21):
return("scorpio")
elif (int(month) == 11 and int(day) <= 22) or (int(month) == 12 and int(day) <= 21):
return("sagittarius")
elif (int(month) == 12 and int(day) <= 22) or (int(month) == 1 and int(day) <= 20):
return("capricorn")
elif (int(month) == 1 and int(day) <= 21) or (int(month) == 2 and int(day) <= 19):
return("aquarius")
elif (int(month) == 2 and int(day) <= 19) or (int(month) == 3 and int(day) <= 20):
return("pisces")
def interpret_chinese_sign(year):
year = int(year)
if year % 12 == 0:
return ("monkey")
elif year % 12 == 1:
return ("rooster")
elif year % 12 == 2:
return ("dog")
elif year % 12 == 3:
return ("pig")
elif year % 12 == 4:
return ("rat")
elif year % 12 == 5:
return ("ox")
elif year % 12 == 6:
return ("tiger")
elif year % 12 == 7:
return ("rabbit")
elif year % 12 == 8:
return ("dragon")
elif year % 12 == 9:
return ("snake")
elif year % 12 == 10:
return ("horse")
else:
return ("sheep")
def interpret_both_signs(day, month, year):
x = (interpret_western_sign(day,month), interpret_chinese_sign(year))
return x
print (interpret_both_signs(day, month, year))