Решение на Да си приготвим нещо за хапване от Любомир Ваньов

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

Към профила на Любомир Ваньов

Резултати

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

Код

n=1;
def prepare_meal(number):
if (number%3**n==0) & (number%5==0):
print('spam and eggs')
elif number%5==0:
print('eggs')
elif number%3**n==0:
print('spam')
else:
print('')

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

FFFFFFFFFF
======================================================================
FAIL: test_eggs (__main__.FirstHomeworkTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/test20120506-8116-1ap6q0u", line 19, in test_eggs
    self.assertEqual('eggs', self.solution.prepare_meal(5))
AssertionError: 'eggs' != None

======================================================================
FAIL: test_eggs_with_additional_egg_multipliers (__main__.FirstHomeworkTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/test20120506-8116-1ap6q0u", line 22, in test_eggs_with_additional_egg_multipliers
    self.assertEqual('eggs', self.solution.prepare_meal(5**4))
AssertionError: 'eggs' != None

======================================================================
FAIL: test_eggs_with_additional_nonegg_multipliers (__main__.FirstHomeworkTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/test20120506-8116-1ap6q0u", line 25, in test_eggs_with_additional_nonegg_multipliers
    self.assertEqual('eggs', self.solution.prepare_meal(5*7*11))
AssertionError: 'eggs' != None

======================================================================
FAIL: test_no_spam_or_eggs (__main__.FirstHomeworkTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/test20120506-8116-1ap6q0u", line 7, in test_no_spam_or_eggs
    self.assertEqual('', self.solution.prepare_meal(11))
AssertionError: '' != None

======================================================================
FAIL: test_one_spam (__main__.FirstHomeworkTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/test20120506-8116-1ap6q0u", line 10, in test_one_spam
    self.assertEqual('spam', self.solution.prepare_meal(3))
AssertionError: 'spam' != None

======================================================================
FAIL: test_some_spam_and_eggs (__main__.FirstHomeworkTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/test20120506-8116-1ap6q0u", line 31, in test_some_spam_and_eggs
    self.assertEqual('spam spam and eggs', self.solution.prepare_meal(45))
AssertionError: 'spam spam and eggs' != None

======================================================================
FAIL: test_some_spams (__main__.FirstHomeworkTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/test20120506-8116-1ap6q0u", line 13, in test_some_spams
    self.assertEqual('spam spam spam spam', self.solution.prepare_meal(81))
AssertionError: 'spam spam spam spam' != None

======================================================================
FAIL: test_some_spams_with_additional_multipliers (__main__.FirstHomeworkTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/test20120506-8116-1ap6q0u", line 16, in test_some_spams_with_additional_multipliers
    self.assertEqual('spam spam spam spam', self.solution.prepare_meal(81*2*7*11))
AssertionError: 'spam spam spam spam' != None

======================================================================
FAIL: test_spam_and_eggs (__main__.FirstHomeworkTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/test20120506-8116-1ap6q0u", line 28, in test_spam_and_eggs
    self.assertEqual('spam and eggs', self.solution.prepare_meal(15))
AssertionError: 'spam and eggs' != None

======================================================================
FAIL: test_spam_and_eggs_with_additional_multipliers (__main__.FirstHomeworkTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/test20120506-8116-1ap6q0u", line 34, in test_spam_and_eggs_with_additional_multipliers
    self.assertEqual('spam spam and eggs', self.solution.prepare_meal(45 * 8 * 7))
AssertionError: 'spam spam and eggs' != None

----------------------------------------------------------------------
Ran 10 tests in 0.003s

FAILED (failures=10)

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

Любомир обнови решението на 15.03.2012 15:33 (преди над 8 години)

+n=1;
+def prepare_meal(number):
+ if (number%3**n==0) & (number%5==0):
+ print('spam and eggs')
+ elif number%5==0:
+ print('eggs')
+ elif number%3**n==0:
+ print('spam')
+ else:
+ print('')