Computer Science, asked by arohi1491, 1 year ago

pls help

python program for odd and even number​

Answers

Answered by fiercespartan
3

For a number to be even in python, the remainder when the number is divided by 2 would be 0. Or, if the number is odd, the remainder can be any greater than 0.

To find a remainder in python, we use the symbol '%'. This is called as a modulo.

_____________________________________________

CODE:

def find(n):

   return 'Even' if n%2 == 0 else 'Odd'

print(find(int(input('Enter the number:'))))

#Alternative code in one line down below:

____________________________________________

print('Even' if int(input('Enter the number:'))%2 == 0 else 'Odd')

____________________________________________

Similar questions