DS301222 #What is the use of Function explain with example in python

Ans: A function is a block of code which only runs when it is called.
You can pass data, known as parameters, into a function.
A function can return data as a result.

Creating a Function
In Python a function is defined using the def keyword:

Example:-
def my_function():
print(“Hello from a function”)

#Calling a Function
To call a function, use the function name followed by parenthesis:
Example

def my_function():
print(“Hello from a function”)

my_function()

3 Likes

Good explanation @vaishu.swap10112016

Very good :fire: explained very well