Computer Science Related Others Courses AvailableThe Best Codder.blogspot.com
Posts

Python Program to Check if a Number is Odd or Even

 

Python Program to Check if a Number is Odd or Even

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.

See this example:

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

Output:

Python Condition And Loops3

Post a Comment

© Python . The Best Codder All rights reserved. Distributed by