# 05. Write a Python Program to Check if a Number is Odd or Even ?

## Introduction :

Hello friends, in today’s post, I am going to tell you how you can check in Python whether any number is odd or even, so if you also want to know about it, then read this post till the end. read carefully so that you understand everything correctly

## Python Code to Check if Number is Odd or Even :

```
def check_odd_even(num):
if num % 2 == 0:
return "Even"
else:
return "Odd"
print(check_odd_even(5))
print(check_odd_even(10))
```

## Explanation :

The program defines a function check_odd_even(num) that takes an integer as an argument. Inside the function, we use the modulus operator (%) to check if the number is divisible by 2. The modulus operator returns the remainder when one number is divided by another. In this case, we use it to check if the remainder when num is divided by 2 is equal to 0.

`if num % 2 == 0:`

If the remainder is equal to 0, that means the number is divisible by 2 and therefore even. In this case, the code block inside the if statement runs and the function returns the string “Even”.

`return "Even"`

If the remainder is not equal to 0, that means the number is not divisible by 2 and therefore odd. In this case, the else block runs and the function returns the string “Odd”.

```
else:
return "Odd"
```

The function can be called by passing an integer as an argument, for example:

```
print(check_odd_even(5)) # Output: Odd
print(check_odd_even(10)) # Output: Even
```

In this example, when the function check_odd_even(5) is called, it returns “Odd” because 5 is not divisible by 2. Similarly, when the function check_odd_even(10) is called, it returns “Even” because 10 is divisible by 2.

It’s a simple program that check if a number is even or odd, it doesn’t use any advanced functionality or libraries, it’s a basic program that uses only the basic concepts of python.

## Output :

```
Odd
Even
```