Odd Even number Program in Python
Advertisements
Check Odd Even number Program in Python
Using modulus Operator we can check odd and even number. If remainder is zero 'Even number' other wise odd number.
Odd Even number Program in Python
num = int(input("Enter any number: ")) rem = num % 2 if rem > 0: print("Odd number.") else: print("Even number.")
Output 1
Enter any number: 24 Even number
Output 2
Enter any number: 25 Odd number
Odd Even number Program in Python
num = int(input("Enter any number: ")) if (num % 2) == 0: print("{0} is Even".format(num)) else: print("{0} is Odd".format(num))
Output 1
Enter any number: 12 12 is Even number
Output 2
Enter any number: 13 13 is Odd number
Google Advertisment