Python Program to Find Even or Odd

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.

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

  1. We are taking input from the user and typecasting it into an integer.
  2. We are using the modulus operator to check if the number is even or odd.
  3. If the number is divisible by 2, it is even.
  4. If the number is not divisible by 2, it is odd.
  5. We are printing the result.

Leave a Comment

Share to...