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
Updated on 30-Jul-2019 22:30:21