A Program to Check if a Number is Even or Odd

In this example, we are giving a program to check if a number is even or odd.


Program to swap to check if a number is even or odd:

  1. # Check if a number is even or odd
  2. num = float(input('Enter a number: '))
  3. if(num % 2 ) == 0:
  4. print("{0} is Even".format(num))
  5. else:
  6. print("{0} is Odd".format(num))

Output:

Enter a number: 57
57.0 is Odd