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.