Program to find odd and even number

This blog demonstrate the use of if and else condition to find odd and even number

Asking user to input

num = int(input('Enter any number: '))

Divide the number by 2. Number is even if the remainder after modulus operation is zero. Otherwise number is odd

if num%2 == 0:
print('Entered number %d is Even'%num)
else:
print('Entered number %d is Odd'%num)

Output

Enter any number: 3
Entered number 3 is Odd

Output

Enter any number: 6
Entered number 6 is Even

Complete Code

num = int(input('Enter any number: '))
if num%2 == 0:
    print('Entered number %d is Even'%num)
else:
    print('Entered number %d is Odd'%num)
Advertisement

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s