Write a Python function named "is_even" that takes an integer as input and returns True if the number is even, and False otherwise.use python
时间: 2024-03-10 11:45:36 浏览: 260
判断输入的是否是正数
Sure! Here is the code for the "is_even" function in Python:
```python
def is_even(num):
if num % 2 == 0:
return True
else:
return False
```
This function takes an integer "num" as input and uses the modulo operator (%) to check if the number is divisible by 2. If the remainder is 0, then the number is even, so the function returns True. Otherwise, the function returns False.
阅读全文