How to check if a number is odd or even without modulus operator in Python

1 Answer

0 votes
def is_even(n):
    return int(n / 2) * 2 == n

    
n = 13; 

print("Even") if is_even(n) else print("Odd")


  
'''
run:
  
Odd
  
'''

 



answered Mar 27, 2019 by avibootz

Related questions

...