Functions#

Susanna Lange

Instead of writing a line of code multiple times to perform some action more than once, it might be advantageous to check if Python has a built-in function that already does what we want! If not, we can create our own functions in Python!

Both functions built-in to Python and those user-created follow the general format of mathematical functions of which you may be familiar. They require an input, or an argument, to the function, and they provide or compute some output. This section covers the foundations behind using built-in functions and how to create our own. Additionally, we consider methods in this section, which is a category of functions that pertain to a specific object, or type.