Functions are the basic building blocks of all the programs that we write. They are the first major control structure that we will study. A control structure is code that dictates which line(s) of code will be executed at a particular point in a program.
A function is a conveniently packaged set of instructions (lines of code) that together accomplish some common operation.
We’ve seen functions already with the print()
function and the casting functions. Now we’ll learn about both how to use other functions that are already provided by python (“built-in” functions) and how to write our very own functions.
Warning! Functions can be a confusing topic. A good understanding of functions is vital to programming in any language, so making sure to carefully go through this material is essential.