Functional programming
Functional programming is a paradigm that originates from the lambda calculus (λ-calculus), a formal system in mathematics that can be used to simulate any Turing machine. Without diving too much into the λ-calculus, this means that computation is performed using only the function arguments as input and that the output consists of a new variable without mutating the input variables. With a strictly functional programming language this behavior would be enforced, but since Python is not a strictly functional language, this doesn’t necessarily hold true.
It is still a good idea to adhere to this paradigm since mixing paradigms can cause unforeseen bugs, as discussed in Chapter 3, Pythonic Syntax and Common Pitfalls.
Purely functional
Purely functional programming expects functions to have no side effects. That means that arguments given to the function should not be mutated, and neither should any other external states. Let’...