Q:

Python Program to Check if a Number is Odd or Even

belongs to collection: Python Basic Programs

0

Odd and Even numbers:

If you divide a number by 2 and it gives a remainder of 0 then it is known as even number, otherwise an odd number.

Even number examples: 2, 4, 6, 8, 10, etc.

Odd number examples:1, 3, 5, 7, 9 etc.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

num = int(input("Enter a number: "))  
if (num % 2) == 0:  
   print("{0} is Even number".format(num))  
else:  
   print("{0} is Odd number".format(num))  

Output:

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Python Program to Check Leap Year... >>
<< Python Program to check if a Number is Positive, N...