Functions is a sub-routine which contains set of statements. Usually functions are written when multiple calls are required to same set of statements which increases re-usuability and modularity. Function gets run only when it is called.
How to define a Function
def function_name(parameters):
#code
How to call a Function
function_name (parameters)
Example
def greeting(name):
print("Happy learning" + " " + name + "!")
greeting("foo")
Result of the above sample program is:
Happy learning foo!