Whenever you write some Python source code, the code you create will perform a task of some sort. Maybe your code analyzes some data, stores some information into a file, or prompts the user to choose an item from a list. It doesn't matter what your code is—ultimately, your code does something.
Often, this something is very specific. For example, you might have a function that calculates compound interest, generates a Venn diagram, or displays a warning message to the user. Once you've written this code, you can then use it wherever you want in your own program. This is the simply abstraction pattern that was described in the previous chapter: you separate what you want to do from how you do it.
Once you've written your function, you can then call it whenever you want to perform that task. For example, you can call your
display_warning() function whenever you want to display a warning to the user, without worrying about the details of how the warning...