Our first program will demonstrate functions in Python. Here’s the full source code with explanations:
To run the program, save it as functions.py and use the Python interpreter:
Python functions are first-class objects, which means they can be assigned to variables, stored in data structures, passed as arguments to other functions, and even returned as values from other functions.
There are several other features to Python functions. One is multiple return values, which we’ll look at next.