Functions in Python.



Functions:


A function is a block of code which only runs when it is called. We can pass data, known as parameters or we can also say arguments or signature into a function. A function can return data as a result.

Creating a Function in Python:

In Python, we create a function by using the def keyword.

def result():
    print("welcome to Engine-4-Geeks")


Calling Function:

def result():
    print("welcome to Engine-4-Geeks")
result()


Passing argument in Function:

We can pass some information as an argument in python function. Arguments are specified after the function name, inside the parentheses. You can add as many arguments as you want, just separate them with a comma.

def naming(name):
    print("Name : "+ name)
naming("John")
naming("Joe")
naming("Lava")




    

Post a Comment

0 Comments