How to Check if a Number is Odd or Even using Python?

PythonServer Side ProgrammingProgramming

Python's modulo (%) operator (also called remainder operator) is useful to determine if a number is odd or even. We obtain remainder of division of a number by 2. If it is 0 , it is even otherwise it is odd

no=int(input('enter number'))
if no%2==0:
    print ('{} is even'.format(no))
    print ('{} is odd'.format(no))

The output

enter number25
25 is odd

enter number40
40 is even
Published on 27-Feb-2018 19:57:50