Wednesday 15 August 2018

Function in Python

We will now write a function in Python :

-----------------------
def add(x, y):
    return x + y

print(add(2, 3))
-----------------------

Above function name is add, it expects two arguments x and y and returns their sum. Notice how we are printing and calling add function in last line

The output of above program is below:

-----------------------
5
-----------------------

No comments:

Post a Comment