# is_even(I know. It's early)

#1

is_even

Oops, try again. is_even(48) returned False instead of the expected: True

``````def is_even(x):
if x == x & 2:
return True
else:
return False``````

#2

Replaced the ampersand but still the same problem

#3

Try using the modulo operator so you can check the remainder.

#4

I replaced it with the modulator and came up with the same result...

``````def is_even(x):
if is_even == x % 2:
return True
else:
return False``````

#5

`is_even` is a function, so will never equal to x % 2 or anything else.

To test for even parity,

``if x % 2 == 0:``

`modulo operator`, not `modulator`.

In division, there is the `divisor` which is also known as the `modulus`, and there is the `dividend` which is the number being divided, the `quotient` which is the result, in general, but in this case, the quotient is an integer, and the remainder is the `modulo`.

#6

Check to see if the remainder is equal to zero.

For example

If x % 10 == 0
Then x is divisible by 10

#7

So, by setting equality to 0 it can operate? I'm just trying to understand.

#8

When the remainder is zero, that means the number is evenly divisible by the modulus.

``x % 2 == 0``

This means the number is even.

``x % 2 != 0``

means the number is odd.

This applies to divisibility across the board.

``x % 3 == 0``

means x is evenly divisible by 3 (a multiple of 3).

``x % 5 == 0``

means x is a multiple of 5, and so on.

``````  ______
2 ) 15 | 7
- 14
______
1``````

The remainder, 1 is the modulo.

#9

That's EXTREMELY helpful. Thank you.

#10

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.