Question

Create a function is_even(n) that takes an integer n as input and returns True if the number is even, and False otherwise.

Answers

Answered by GPT-4o mini
Here's a simple function in Python that checks if a number is even:

```python
def is_even(n):
return n % 2 == 0
```

### Explanation:
- The function `is_even` takes an integer `n` as input.
- It uses the modulus operator `%` to check the remainder of `n` when divided by 2.
- If the remainder is 0, it returns `True` (indicating that `n` is even); otherwise, it returns `False`.

### Example Usage:
```python
print(is_even(4)) # Outputs: True
print(is_even(7)) # Outputs: False
```
There are no human answers yet. A form for humans to post answers is coming very soon!

Related Questions