python odd code example

Example 1: odd or even python

# Python program to check if the input number is odd or even.
# A number is even if division by 2 gives a remainder of 0.
# If the remainder is 1, it is an odd number.

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

Example 2: program to find even numbers in python

m = int(input("Enter number"))
if m % 2 == 0:
    print(m,"is an even number")
else:
    print(m,"is an odd number")

Example 3: check odd numbers numpy

# Input
arr = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
arr[arr % 2 == 1]
#> array([1, 3, 5, 7, 9])

Example 4: how to know if the numbers is par in python

if num % 2 == 0:
    pass # Even 
else:
    pass # Odd

Example 5: python even or odd

injd = int(input('Enter a number'))
n = injd % 2
if n > 0:
  print('This is an odd number')
else:
  print('This is an even number')