Even Odd Program in Python

Even numbers are divisible by 2 with no remainder. It ends with 0, 2, 4, 6, or 8 (e.g., 74). where Odd numbers leave a remainder when divided by 2, and end in 1, 3, 5, 7, or 9 (e.g., 71). Zero is an even number. Now, let's code the even and odd programs in Python by using the divisibility logic.
Note: The number 0 is considered an even number. As 0 ends with one of the numbers (0, 2, 4, 6, 8).
Check Even or Odd Number in Python
Let us code the even and odd numbers in python program.
Transform Your Career
Choose from our industry-leading programs designed for career success
Modern Software and AI Engineering Program
Master full-stack development with AI integration
+1000 moreModern Data Science and ML with specialisation in AI
Advanced data science techniques with AI specialization
+1000 moreAdvanced AIML with Specialisation in Agentic AI
Deep dive into AIML with focus on Agentic systems
+1000 moreDevOps, Cloud & AI Platform Engineering
Build and manage AI-powered cloud infrastructure
+1000 moreAI Engineering Advanced Certification by IIT-Roorkee
Premier AI engineering certification from IIT-Roorkee
Even Odd Program in Python Using Division
We will divide the given number by 2. If the number gets completely divided by 2 then the number is an even number. Else, the number is not an even number (i.e. odd number).
The pseudoscope for the even off program in python can be:
Function Name: even_odd(number)
Note: We can use the modulo operator in python % to find the remainder. The modulo operator in python returns the remainder of a division between two numbers.
Code:
Output:
Check Even or Odd Numbers using recursion in Python
We can also use recursion in even-odd programs in python. We will call the recursive function until it is greater than 1, it become 0 then called even and called odd.
Output:
Turn Learning into Career Growth
Even Odd Program in Python Using Bitwise Operator
We can also use Bitwise Operators in even-odd programs in python. Bitwise Operators are the operators that help us to perform bit (bitwise) operations. Bit operators are ~, << >>, &, ^, |.
Using the bitwise operator, we will check if the last bit of the number is set or not. If the last bit is set then the number must be odd. Else, the number will be an even number.
Code:
Output:
Conclusion
- Even numbers are the numbers that can be completely divided by 2 without leaving any remainder.
- On the other hand, odd numbers are the numbers that can not be completely divided by 2 (leaves a remainder when divided by 2).
- We can code the even-odd program in python using divisibility logic and bitwise operator.