Calling functions#
Programming concept
Functions are a defined chunk of code which carries out a specific task or function.
We have come across a few functions already e.g., print()
. Function names are always followed by parentheses and are
called in the following way function_name(argument1, argument2, ...)
. They take an input, also known as an
argument (or arguments, if more than one) and after processing it returns an output. One can think of a function
as a black box, where an input is fed in, the code inside the function will process it, and a processed output is returned.
This process is shown in (A) shows the different components of a function. (B) shows an example of the function abs(). below.

Fig. 3 (A) shows the different components of a function. (B) shows an example of the function abs()
.#
In the example above, we see an example with the built-in function abs()
which returns the absolute value of a number.
It takes as an input, -20, (the argument), and returns the processed output, 20. A list of built-in functions in
Python can be found here. We will also be looking at how we can
create functions later on.