Python program to check number is odd or not

Solution with out using functions
Solution using functions without passing arguments
Solution using functions and by passing arguments


Solution : Without using function
Program/Source Code

For better understanding of this example, one should have the knowledge of the following Python programming topics:

Python if…else… Statement
Python if…else…if…else… Statement
Python if…elif…if…elif…else… Statement

Python program to check number is odd or not

a=int(input("Enter any no "))
if(a%2==1): #or if(a%2==1):
    print("Number is odd")
else:
    print("Number is not odd")

Output:

Enter any no 62
Number is not odd
>>>
Enter any no 95
Number is odd
>>>



Solution : Using function Without Passing Arguments
Program/Source Code

#function definition
def odd():
    a=int(input("Enter any no "))
    if(a%2==1): #or if(a%2==1):
        print("Number is odd")
    else:
        print("Number is not odd")

#function calling
odd()

Output:

Enter any no 21
Number is odd
>>>

Enter any no 28
Number is not odd
>>>



Solution : Using function Passing Arguments
Program/Source Code

#function definition
def odd(a):
    if(a%2==1): #or if(a%2==1):
        print("Number is odd")
    else:
        print("Number is not odd")

#function calling
a=int(input("Enter any no "))
odd(a)

Output:

Enter any no 95
Number is odd
>>>
Enter any no 902
Number is not odd
>>>

You May Also Like:

Python Program to Check person can vote or not
Python Program to check character is a vowel or not
C Language Program to Print Fibonacci Series
Python Program to Print Fibonacci Series
C Language Program for Factorial of a Number

Tutorials

Technical Questions and Important programs

Interview Questions

C Programming
C++ Programming
Basic Python Tutorial
Advanced Python Tutorial
C Language
C++ Programming
Python programming
C Important Programs
C Interview Questions
C++ Interview Questions
Python Interview Questions
HTML Interview Questions


Visitor Counter

0056750