Write a program to check if a number is odd or even.

 Q. Write a program to check if a number is odd or even.

Code:-

Method - 1
num = float(input("Enter a number:"))
if (num % 2) == 0:
  print("The number is even.")
else:
  print("The number is odd.")


Method - 2
num = float(input("Enter a number:"))
if (num % 2) != 0:
  print("The number is odd.")
else:
  print("The number is even.")

Output:-


Comments