Even Odd Program in Python

Learn via video course
FREE
View all courses
Python Course for Beginners With Certification: Mastering the Essentials
Python Course for Beginners With Certification: Mastering the Essentials
by Rahul Janghu
1000
4.90
Start Learning
Python Course for Beginners With Certification: Mastering the Essentials
Python Course for Beginners With Certification: Mastering the Essentials
by Rahul Janghu
1000
4.90
Start Learning
Topics Covered

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

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program

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

1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary
1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary

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.

See Also

Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more