🔹 Functions in Python
A function is a block of code which only runs when it is called.
we can pass data, known as parameters, into a function.
A function can return data as a result.
# In Python a function is defined using the def keyword:
🔸 Example : Creating a Function
def my_function():
print("Hello function")
print("Hello function")
🔸 Calling a Function
To call a function, we use the function name followed by parenthesis
Example :
def my_function():
print("Hello from function")
my_function() # Here is Function call by its name
print("Hello from function")
my_function() # Here is Function call by its name
No comments:
Post a Comment