Functions

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 ...

Get Scientific Computing with Python - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.