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
```

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
```

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
```

`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`

.

Check to see if the remainder is equal to zero.

For example

If x % 10 == 0

Then x is divisible by 10

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.

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