What are functions in Python?

Hi, can anyone explain What are functions in Python

As we know, a function is a piece of code that executes when it is called. We always pass the parameters into a function.

In python, we define a function with def keyword.

For Example:

def evenOdd(a):
if (a % 2 == 0):
    print "Number is even"
    print "Number is odd"

Here evenOdd is a function and a is a parameter. Hope it helps.

1 Like