Even numbers are numbers that are evenly divided into two groups, such as 2, 4, 6, 8, 10.
Odd numbers are numbers that are not evenly divided into two groups, such as 1, 3, 5, 7, 9.
Table of Contents
show
Program Code
num = int(input("Enter a number: "))
if (num % 2) == 0:
print("{0} is Even".format(num))
else:
print("{0} is Odd".format(num))
Input Given:
Enter a number: 69
Expected Output:
69 is Odd
Code Explanation
- We are taking input from the user and typecasting it into an integer.
- We are using the modulus operator to check if the number is even or odd.
- If the number is divisible by 2, it is even.
- If the number is not divisible by 2, it is odd.
- We are printing the result.