def is_prime(val): """this predicate function to check the prime number""" if val < 2 or (val > 2 and is_even(val)): return False elif val == 2: return True for i in range(3, val, 2): if is_divided_by(val, i): return False return True
def test_negative_odd_numbers_are_not_even(): assert not is_even(-1) assert not is_even(-3) assert not is_even(-5)
def test_negative_even_numbers_are_even(): assert is_even(-2) assert is_even(-4) assert is_even(-6)
def test_odd_numbers_are_not_even(): assert not is_even(1) assert not is_even(3) assert not is_even(5)
def test_even_numbers_are_even(): assert is_even(2) assert is_even(4) assert is_even(6)
def test_zero_is_even(): assert is_even(0)
def test_even(): assert is_even(2) assert is_even(4) assert is_even(0) assert is_even(2232986)
def test_odd(): assert not is_even(3) assert not is_even(7) assert not is_even(-1) assert not is_even(398345)
def test_even(self): from even import is_even self.assertEqual(is_even(1), False) self.assertEqual(is_even(2), True)
def test_two(): assert even.is_even(4)
def test_one(): assert even.is_even(2)
from even import is_divisible_by_3_5_7, is_even check_numbers = [45, 2345, 56, 105] for number in check_numbers: result = is_even(number) if result == True: print(f"{number} is even.") else: print(f"{number} is ood.") for number in check_numbers: result = is_divisible_by_3_5_7(number) if result: print(f"{number} is divisible by 3, 5 and 7.") else: print(f"{number} is NOT divisible by 3, 5 and 7.")
def test_is_five_even(self): """Is five successfully determined to be even?""" self.assertTrue(is_even(7))