Many times we write code we want to reuse again and again in different situations. One could say that all of software is code of instructions bundled in a way to be reused again and again in different situations. The most essential building block of such a code is functions.
You can probably draw many parallels between functions in Mathematics and functions in Python. For the most part the notion is the same.
Functions in python take an input and apply a set of instructions to it.
#Example Addition function
def add(a,b):
total = a + b
return total
The above function can take 2 numbers, add them up and output the result. Notice that we use a return statement to output the result. This in general is not necessary. This function
def add(a,b):
total = a + b
would be perfectly good code in terms of python syntax and would run without errors. The result gets assigned to the variable total which is a local variable inside the function add(). We would just never get the total variable and therefore the result out of the function which would make it bad code in terms of its usability even if it is syntacticly correct.