We will be using if … else condition statement to determine whether the number enter by user is odd or even.

Below is the logic to determine odd and even number

- Use % modulus operator which provides remainder of the division
- If number is divided by 2 and remainder is 0 then it is even number otherwise it is odd number.

Asking to enter any number.

number = int(input('Please enter any number: '))

Now checking whether division of number by 2 provides remainder 0 or not. If remainder is 0 then it is even number otherwise odd number.

if number%2 == 0:
print('Number %s is Even'%number)
else:
print('Number %s is Odd'%number)

OUTPUT

Please enter any number: 25
Number 25 is Odd

Running the same program and providing 66 value

Please enter any number: 66
Number 66 is Even

Complete Code

number = int(input('Please enter any number: '))
if number%2 == 0:
print('Number %s is Even'%number)
else:
print('Number %s is Odd'%number)

### Like this:

Like Loading...

*Related*