
問題描述:
Check if the given number is even or not. Your function should return True if the number is even, and False if the number is odd.
Input: An int.
Output: A bool.
def is_even(num: int) -> bool:
# your code here
return False
if __name__ == '__main__':
print("Example:")
print(is_even(2))
# These "asserts" are used for self-checking and not for an auto-testing
assert is_even(2) == True
assert is_even(5) == False
assert is_even(0) == True
print("Coding complete? Click 'Check' to earn cool rewards!")
判斷數字是否是偶數,看數字能不能被2整除就好了。
def is_even(num: int) -> bool:
# your code here
return num%2==0