Notification texts go here Contact Us Buy Now!

Checking Odd or Even Integer Using Python

Hello bloggers!

In this post, we'll discuss a simple Python function to check if an entered integer is odd or even.

The Python Function

Here's the Python function:


def check_odd_even(number):
    if number % 2 == 0:
        return "Even"
    else:
        return "Odd"

# Example usage:
number = int(input("Enter an integer: "))
result = check_odd_even(number)
print("The entered integer is", result)
  

Explanation

This function takes an integer as input and checks if it's divisible by 2. If it is, the function returns "Even"; otherwise, it returns "Odd".

Example Usage

Let's say we have the following usage:


Enter an integer: 7
The entered integer is Odd
  

In this example, the function determines that the entered integer (7) is odd.

You can test this function with different integers to check if they are odd or even.

About the Author

Coding | Riding | Music, Embracing the beauty of code, the thrill of the ride, and the rhythm of life. Let's explore the journey together!

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.
Code Copied!