Oscar ChongPro Student 292 Points
Pls help me out
the question is :
Write a function named even_odd that takes a single argument, a number.
return True if the number is even, or False if the number is odd.
You can use % 2 to find out the remainder when dividing a number by 2. Even numbers won't have a remainder..
Can you pls tell me what should i do? Thanksss
def even_odd(num): while True: if num == even: return True else: return False
Oli Flemmer12,711 Points
You need to use % to find out if a number is odd or even. What % does is find the remainder of a division calculation; for example 9 % 4 = 1 . This is because 9 divided by 4 is 2 REMAINDER 1. All even numbers % 2 = 0. And all odd numbers % 2 = 1. E.g 6% 2 = 0 and 5 % 2 = 1. You can wright an if statement to check if num % 2 = 0 or 1. If it’s 0 then it’s even and you can return False if it’s 1 then you can return True.
Try and attempt to do the chanllenge on your own, but I’m going to leave my code below.
def even_odd(num): if num % 2 == 0: #even return False if num % 2 == 1: #odd return True