Different Methods to Find Even or Odd number with Python Examples.

Python is a friendly programming language. Python is Easy to read, understand, and learn. But every skill needs your time and dedication. you need to practice to learn and upskill. In this journey of learning the syntax of programming languages,we practcie simple examples.


This blog post explains different approaches to find even or odd numbers using Python. The list of contents are:

Method 1: Modulus Operator %

  1. Method 2: List Comprehension
  2. Method 3: Using Lambda Functions
  3. Method 4: Using Bitwise Operators
  4. Method 5: Using a Custom Function
  5. Method 6: Using NumPy for Larger Datasets


To learn all methods to find even or odd, click here.


  1. Method 2: List Comprehension

List Comprehension is a pythonic ways to apply specific operations on a list of data, In less code we can filter a large collection of data. Let’s apply List Comprehension to filter EVEN or ODD in a given list:

# Filtering even and odd numbers using list comprehensions
numbers = [1, 2, 3, 4, 5, 6]

evens = [num for num in numbers if num % 2 == 0]
odds = [num for num in numbers if num % 2 != 0]

print(f"Even numbers: {evens}")
print(f"Odd numbers: {odds}")        

How It Works:

  • The list comprehension iterates over numbers and applies a condition ( num % 2 ==0 ) for evens, (num %2!=0


click here to learn complete blog post

要查看或添加评论,请登录

Lal Babu Ray的更多文章

社区洞察

其他会员也浏览了