This post contains a total of 14+ Hand-Picked Python Odd-Even Program Examples with Source Code. All the Odd-Even programs are made using Python Programming Language.
You can use the source code of these programs for educational purpose with credits to the original owner.
Related Posts
Click a Code to Copy it.
1. By David Ashton
Made by David Ashton. Python Even or Odd without Ifs or Loops. ( Source )
442 Even
print(["Even", "Odd"][int(input()) % 2])
2. By BlackRose Mike
Made by BlackRose Mike. Odd or even program without using conditions. ( Source )
Enter a number to check if even or odd: 27 27 is odd?: True
def Checker(num):
result = num%2 == 0
return result
num = input("Enter a number to check if even or odd: " ) or '2'
num = int(num)
check = Checker(num)
print()
print(" %d is even?: %s" % (num, check))
3. By Shruthii
Made by Shruthii. Python Program to check if a number is odd or even, also prints the rest of the odd or even numbers in 9 number range. ( Source )
enter a numberthe number 1 is odd 1 3 5 7 9 11 13 15 17
n= int(input("enter a number"))
p= n
if(n%2==0):
print("the number",n,"is even")
else:
print("the number",n,"is odd")
for i in range(9):
print (p)
p=p+2
4. By David Ashton
Another Odd Even program by David Ashton. ( Source )
1234 1234 is even.
n = int(input())
print(f"{n} is {'odd' * (n % 2)}{'even' * (not n % 2)}.")
5. By Christine
Made by Christine. ( Source )
214 Your integer 214 is even.
a = input() #Enter your integer in the input.
try:
if int(a) % 2 == 0:
print('Your integer ', a, 'is even.')
elif int(a) % 2 == 1:
print('Your integer', a, 'is odd.')
except:
print("Please enter an integer.")
print()
print("Thanks for checking out this code! I started this a long time ago before I knew too much Python so it had to wait. Thanks to Toni Isotalo and Pulkit Kamboj for help on this project when I was a Python noob. :P")
6. By Chandini
Made by Chandini. This program outputs even and odd numbers in the given range. ( Source )
5 0 is even 1 is odd 2 is even 3 is odd 4 is even 5 is odd
n=int(input())
for i in range(0,n+1,1):
if i%2==0:
print(i," is even")
else:
print(i," is odd")
7. By π Prometheus πΈπ¬
Made by π Prometheus πΈπ¬. Program for sorting multiple numbers into odd and even. Odd at left and Even at Right. ( Source )
[1, 3, 5, 9, 4, 2, 6, 8]
a=[1,3,4,5,2,6,9,8] #can edit this to need
odds=[]
even=[]
for i in a:
if i%2==1:
odds+=[i]
else:
even+=[i]
print(odds+even)
8. By Automation
Made by Automation. Program that asks for a number and finds if it is odd or even. ( Source )
Input a number: 0 Input the second number: 10 The number is even and a multiple of four 0 divided by 10 is possible.
x = int(input("Input a number: "))
print(str(x))
y = int(input("Input the second number: "))
print(str(y))
if x%2==0:
if x%4==0:
print("The number is even and a multiple of four")
else:
print("The number is even")
else:
print("The number is odd")
if x%y==0:
print(str(x) + " divided by " + str(y) + " is possible.")
else:
print(str(x) + " divided by " + str(y) + " is not possible.")
9. By TOLUENE
Made by TOLUENE. Enter your number in digit. ( Source )
2 2 is even
n = str(input())
digit="0123456789"
if n[-1] in digit[0:10:2]:
print(f"{n} is even")
else:
print(f"{n} is odd")
10. By David Carroll
Made by David Carroll. Program for Segregating odd / even Numbers. Given a list as [8,1,6,4,7,2,13] Output should be: [1, 7, 13, 2, 4, 6, 8] (Left side odd, right side even numbers) Uses no modules and no loops. ( Source )
[1, 7, 13, 2, 4, 6, 8]
def main():
print(segregate([8,1,6,4,7,2,13]))
# Supporting Functions
def segregate(nums):
nums.sort()
return [
*type("odd", nums),
*type("even", nums)
]
def type(type, nums):
return [n for n in nums
if n % 2 == (0 if type == "even" else 1)]
if __name__ == "__main__":
main()
11. By Shwetha
Made by Shwetha. Basic Odd Even program that checks if the number in the code is odd and even. ( Source )
True True
def is_even(x):
if x == 0:
return True
else:
return is_odd(x-1)
def is_odd(x):
return not is_even(x)
print(is_odd(11))
print(is_even(22))
12. By Mohamed Gadaphy Nkwenkwat
Made by Mohamed Gadaphy Nkwenkwat. if & else to test even – odd number. ( Source )
Enter a number 77 77 is an odd number
num =int(input("Enter a number"))
if num % 2==0:
print ('\n',num ,'is an even number')
else :
print ('\n',num ,'is an odd number')
13. By Techno Hassaan
Made by Techno Hassaan. ( Source )
#odd and Even Table
#Just Write 1 or 2 and get Answers
Num = int(input())
for x in range(Num, 102, 2):
if Num == 2 :
print("It's a even number")
if Num == 1:
print ("It's a odd number")
print(x)
#Free Table No Cost ;)
14. By CΓ©pagrave
Made by CΓ©pagrave. ( Source )
19254157 is odd 19254158 is even 238 is even 239 is odd 3477 is odd 3478 is even 111143 is odd 111142 is even
a = 19254157
print(a,'is',['even','odd'][a%2])
a = 19254158
print(a,'is',['even','odd'][a%2])
a = 238
c = str(a/2).replace('.0','even').replace('.5','odd ')[-4:]
print(a,'is',c)
a = 239
c = str(a/2).replace('.0','even').replace('.5','odd ')[-4:]
print(a,'is',c)
a = 3477
c = int(int(str(a/2)[-1])/5)*'odd'+int(int(str(a/2-0.5)[-1])/5)*'even'
print(a,'is',c)
a = 3478
c = int(int(str(a/2)[-1])/5)*'odd'+int(int(str(a/2-0.5)[-1])/5)*'even'
print(a,'is',c)
a = 111143
b = ['oden','even','odd'][(-1)**int(str(a)[-1])]
print(a,'is',b)
a = 111142
b = ['oden','even','odd'][(-1)**int(str(a)[-1])]
print(a,'is',b)
15. By The Coder
Made by The Coder. ( Source )
You entered : 55 This is an odd number
number = int(input ())
y = number/2
print ("You entered :",number )
if y%1 == 0:
print("This is an even number")
else :
print("This is an odd number")