Решение на Хороскоп от Петър Петров

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

Към профила на Петър Петров

Резултати

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

Код

def what_is_my_sign(day, month):
day=raw_input("Enter the number of the day:")
month=raw_input("Now enter the number of the month:")
if (month==3 and day in range(21,32)) or (month==4 and day in range(1,21)):
print("Овен")
elif (month==4 and day in range(21,31)) or (month==5 and day in range(1,21)):
print("Телец")
elif (month==5 and day in range(21,32)) or (month==6 and day in range(1,21)):
print("Близнаци")
elif (month==6 and day in range(21,31)) or (month==7 and day in range(1,22)):
print("Рак")
elif (month==7 and day in range(22,32)) or (month==8 and day in range(1,23)):
print("Лъв")
elif (month==8 and day in range(23,32)) or (month==9 and day in range(1,23)):
print("Дева")
elif (month==9 and day in range(23,31)) or (month==10 and day in range(1,23)):
print("Везни")
elif (month==10 and day in range(23,32)) or (month==11 and day in range(1,22)):
print("Скорпион")
elif (month==11 and day in range(22,32)) or (month==12 and day in range(1,22)):
print("Стрелец")
elif (month==12 and day in range(22,32)) or (month==1 and day in range(1,20)):
print("Козирог")
elif (month==1 and day in range(20,32)) or (month==2 and day in range(1,19)):
print("Водолей")
elif (month==2 and day in range(19,30)) or (month==3 and day in range(1,21)):
print("Риби")
else:
print("Try again")

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

EEEEEEEEEEEEEEE
======================================================================
ERROR: test_aquaris (test.HoroscopeTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130307-16279-1rch7d2/test.py", line 38, in test_aquaris
    self.assertEqual(solution.what_is_my_sign(2, 2), 'Водолей')
  File "/tmp/d20130307-16279-1rch7d2/solution.py", line 2, in what_is_my_sign
    day=raw_input("Enter the number of the day:")
NameError: global name 'raw_input' is not defined

======================================================================
ERROR: test_aries (test.HoroscopeTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130307-16279-1rch7d2/test.py", line 8, in test_aries
    self.assertEqual(solution.what_is_my_sign(1, 4), 'Овен')
  File "/tmp/d20130307-16279-1rch7d2/solution.py", line 2, in what_is_my_sign
    day=raw_input("Enter the number of the day:")
NameError: global name 'raw_input' is not defined

======================================================================
ERROR: test_cancer (test.HoroscopeTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130307-16279-1rch7d2/test.py", line 17, in test_cancer
    self.assertEqual(solution.what_is_my_sign(8, 7), 'Рак')
  File "/tmp/d20130307-16279-1rch7d2/solution.py", line 2, in what_is_my_sign
    day=raw_input("Enter the number of the day:")
NameError: global name 'raw_input' is not defined

======================================================================
ERROR: test_capricorn (test.HoroscopeTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130307-16279-1rch7d2/test.py", line 35, in test_capricorn
    self.assertEqual(solution.what_is_my_sign(1, 1), 'Козирог')
  File "/tmp/d20130307-16279-1rch7d2/solution.py", line 2, in what_is_my_sign
    day=raw_input("Enter the number of the day:")
NameError: global name 'raw_input' is not defined

======================================================================
ERROR: test_gemini (test.HoroscopeTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130307-16279-1rch7d2/test.py", line 14, in test_gemini
    self.assertEqual(solution.what_is_my_sign(16, 6), 'Близнаци')
  File "/tmp/d20130307-16279-1rch7d2/solution.py", line 2, in what_is_my_sign
    day=raw_input("Enter the number of the day:")
NameError: global name 'raw_input' is not defined

======================================================================
ERROR: test_leo (test.HoroscopeTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130307-16279-1rch7d2/test.py", line 20, in test_leo
    self.assertEqual(solution.what_is_my_sign(1, 8), 'Лъв')
  File "/tmp/d20130307-16279-1rch7d2/solution.py", line 2, in what_is_my_sign
    day=raw_input("Enter the number of the day:")
NameError: global name 'raw_input' is not defined

======================================================================
ERROR: test_libra (test.HoroscopeTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130307-16279-1rch7d2/test.py", line 26, in test_libra
    self.assertEqual(solution.what_is_my_sign(5, 10), 'Везни')
  File "/tmp/d20130307-16279-1rch7d2/solution.py", line 2, in what_is_my_sign
    day=raw_input("Enter the number of the day:")
NameError: global name 'raw_input' is not defined

======================================================================
ERROR: test_living_on_the_edge (test.HoroscopeTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130307-16279-1rch7d2/test.py", line 44, in test_living_on_the_edge
    self.assertEqual(solution.what_is_my_sign(20, 6), 'Близнаци')
  File "/tmp/d20130307-16279-1rch7d2/solution.py", line 2, in what_is_my_sign
    day=raw_input("Enter the number of the day:")
NameError: global name 'raw_input' is not defined

======================================================================
ERROR: test_named_arguments (test.HoroscopeTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130307-16279-1rch7d2/test.py", line 50, in test_named_arguments
    self.assertEqual(solution.what_is_my_sign(month=6, day=20), 'Близнаци')
  File "/tmp/d20130307-16279-1rch7d2/solution.py", line 2, in what_is_my_sign
    day=raw_input("Enter the number of the day:")
NameError: global name 'raw_input' is not defined

======================================================================
ERROR: test_pisces (test.HoroscopeTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130307-16279-1rch7d2/test.py", line 41, in test_pisces
    self.assertEqual(solution.what_is_my_sign(9, 3), 'Риби')
  File "/tmp/d20130307-16279-1rch7d2/solution.py", line 2, in what_is_my_sign
    day=raw_input("Enter the number of the day:")
NameError: global name 'raw_input' is not defined

======================================================================
ERROR: test_sagittarius (test.HoroscopeTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130307-16279-1rch7d2/test.py", line 32, in test_sagittarius
    self.assertEqual(solution.what_is_my_sign(11, 12), 'Стрелец')
  File "/tmp/d20130307-16279-1rch7d2/solution.py", line 2, in what_is_my_sign
    day=raw_input("Enter the number of the day:")
NameError: global name 'raw_input' is not defined

======================================================================
ERROR: test_scorpio (test.HoroscopeTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130307-16279-1rch7d2/test.py", line 29, in test_scorpio
    self.assertEqual(solution.what_is_my_sign(7, 11), 'Скорпион')
  File "/tmp/d20130307-16279-1rch7d2/solution.py", line 2, in what_is_my_sign
    day=raw_input("Enter the number of the day:")
NameError: global name 'raw_input' is not defined

======================================================================
ERROR: test_sludge (test.HoroscopeTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130307-16279-1rch7d2/test.py", line 47, in test_sludge
    self.assertEqual(solution.what_is_my_sign(21, 5), 'Близнаци')
  File "/tmp/d20130307-16279-1rch7d2/solution.py", line 2, in what_is_my_sign
    day=raw_input("Enter the number of the day:")
NameError: global name 'raw_input' is not defined

======================================================================
ERROR: test_taurus (test.HoroscopeTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130307-16279-1rch7d2/test.py", line 11, in test_taurus
    self.assertEqual(solution.what_is_my_sign(6, 5), 'Телец')
  File "/tmp/d20130307-16279-1rch7d2/solution.py", line 2, in what_is_my_sign
    day=raw_input("Enter the number of the day:")
NameError: global name 'raw_input' is not defined

======================================================================
ERROR: test_virgo (test.HoroscopeTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130307-16279-1rch7d2/test.py", line 23, in test_virgo
    self.assertEqual(solution.what_is_my_sign(2, 9), 'Дева')
  File "/tmp/d20130307-16279-1rch7d2/solution.py", line 2, in what_is_my_sign
    day=raw_input("Enter the number of the day:")
NameError: global name 'raw_input' is not defined

----------------------------------------------------------------------
Ran 15 tests in 0.004s

FAILED (errors=15)

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

Петър обнови решението на 04.03.2013 13:58 (преди над 11 години)

+def what_is_my_sign(day, month):
+ day=raw_input("Enter the number of the day:")
+ month=raw_input("Now enter the number of the month:")
+ if (month==3 and day in range(21,32)) or (month==4 and day in range(1,21)):
+ print("Овен")
+ elif (month==4 and day in range(21,31)) or (month==5 and day in range(1,21)):
+ print("Телец")
+ elif (month==5 and day in range(21,32)) or (month==6 and day in range(1,21)):
+ print("Близнаци")
+ elif (month==6 and day in range(21,31)) or (month==7 and day in range(1,22)):
+ print("Рак")
+ elif (month==7 and day in range(22,32)) or (month==8 and day in range(1,23)):
+ print("Лъв")
+ elif (month==8 and day in range(23,32)) or (month==9 and day in range(1,23)):
+ print("Дева")
+ elif (month==9 and day in range(23,31)) or (month==10 and day in range(1,23)):
+ print("Везни")
+ elif (month==10 and day in range(23,32)) or (month==11 and day in range(1,22)):
+ print("Скорпион")
+ elif (month==11 and day in range(22,32)) or (month==12 and day in range(1,22)):
+ print("Стрелец")
+ elif (month==12 and day in range(22,32)) or (month==1 and day in range(1,20)):
+ print("Козирог")
+ elif (month==1 and day in range(20,32)) or (month==2 and day in range(1,19)):
+ print("Водолей")
+ elif (month==2 and day in range(19,30)) or (month==3 and day in range(1,21)):
+ print("Риби")
+ else:
+ print("Try again")

Много внимателно прочети пак указанията за предаване на домашни, след което и условието.

  • Откъде го измисли този raw_input? Получаваш стойности като аргумент, никъде не се говори за raw input.
  • Функцията ти не връща нищо, а принтира разни неща по екрана.
  • Виждам 12 еднакви if-а и един излишен else, тъй като сме ви казали да не мислите за невалиден input.
  • Слагаш излишни скоби из тези if-ове и не спазваш конвенциите за интервали из условията.

Oффф... Извинявам се много, това беше първата версия, преди да прочета какво трябваше да пиша... Следващия път ще гледам какво копи пействам, тези неща не трябваше да ги има... :D Наясно съм с това какви са ми грешките. Благодаря!