This chapter introduces functions, a fundamental building block in programming. We show how to define them, how to handle input and output, how to properly use them, and how to treat them as objects.
The following topics are covered in this chapter:
- Functions in mathematics and functions in Python
- Parameters and arguments
- Return values
- Recursive functions
- Function documentation
- Functions are objects
- Anonymous functions – the keyword lambda
- Functions as decorators
7.1 Functions in mathematics and functions in Python
In mathematics, a function is written as a map that uniquely assigns to every element from the domain a corresponding ...