In the previous chapter, we covered the following topics:
How to use looping structures
How to branch within looping structures
How to break out of loops
We will continue to build on this knowledge by implementing what we have learned, to build functions in Python.
Functions are an integral part of the Python programming language, and a lot of languages, really. Throughout this book, you have already encountered some built-in functions, especially when dealing with certain data structures.
Functions are an easy way to group a few lines of code that implement a functionality together. This is especially useful if the code in question will be used several times in different parts of your program. You may want to use functions to abstract away some complex code that you need in your programs. You can think of functions as mini-programs within your bigger program that implement specific tasks.
It is important to remember that while it is tempting to tuck a lot of functionality into a single...