Functions are the structured or procedural programming way of
organizing the logic in the programs.
Functions are often compared to procedures. Both are entities
which can be invoked, but the traditional function or "black box,"
perhaps taking some or no input parameters, performs some
amount of processing and concludes by sending back a return
value to the caller.
Some functions are Boolean in nature, returning a "yes" or "no"
answer, or, more appropriately, a non-zero or zero value.
Procedures, often compared to functions, are simply special cases,
functions which do not return a value.
Python procedures are implied functions because the interpreter
implicitly returns a default value of None.
Calling Functions
Functions are called using the same pair of parentheses that are
used to. In fact, some consider ( ( ) ) to be a two-character
operator, the function operator.
Any input parameters or arguments must be placed between these
calling parentheses.
Parentheses are also used as part of function declarations to define
those arguments.
The concept of keyword arguments applies only to function
invocation. The idea here is for the caller to identify the arguments
by parameter name in a function call. This specification
allows for arguments to be missing or out-of-order because the
interpreter is able to use the provided keywords to match values to
parameters.
Default arguments are those which are declared with default
values. Parameters which are not passed on a function call are
thus allowed and are assigned the default value.
Functions are created using the def statement. The header line consists of the def keyword, the function name,
and a set of arguments (if any).
The remainder of the def clause consists of an optional but
highly-recommended documentation string and the required
function body suite
Functions may return a value back to its caller and those which are
more procedural in nature do not explicitly return anything at all.
Languages which treat procedures as functions usually have a
special type or value name for functions that "return nothing.“
Like most languages, python also return only one value/object from
a function. One difference is that in returning a container type, it will
actually return more than a single object.
In Python, functions are just like any other object. They can be
referenced (accessed or aliased to other variables), passed as
arguments to functions, be elements of container objects like lists
and dictionaries, etc.
The one unique characteristic of functions which may set them
apart from other objects is that they are callable, i.e., can be
invoked via the function operator
A Python function's set of formal arguments consists of all
parameters passed to the function on invocation for which there is
an exact correspondence to those of the argument list in the
function declaration.
These arguments include all required arguments (passed to the
function in correct ordered