You can create and define your own functions. These are useful when you have some code fragments that need to be reused in multiple locations in your code. You can define you required functionality in a function. This function can have parameters.
Here are a few simple examples.
def HelloWorld(): print("HelloWorld") # to call this function HelloWorld()
Now expand this to accept a parameter. In this example it takes a names
print(“HelloWorld : Welcome : “, name)
# to call this function
A function can do anything you want.
def add_numbers(num1, num2): result = num1 + num2 return result # to call this function add_numbers(1, 2)