How to check if a number entered by a user is an even or odd number
In this python program, we will check if a number entered by user is an even number or an odd number. A number is even when it is divided by 2 with no reminder and a number is considered to be odd if a number divided by 2 with a reminder of 1
num = int(input('ENTER A NUMBER: ')
if num % 2 == 0:
print(num + ' IS AN EVEN NUMBER')
elif num % 2 != 0:
print(num + ' IS AN ODD NUMBER')
else:
print('INVALID INPUT!')
CODE |
When a user enters an even number |
When a user input an odd number |
As you can see, our program or code works perfectly as intended
Subscribe My YouTube Channel CODE WITH PETASCO
0 Comments