Skip to content

Learn: Python Functions

Seven short tutorials that build up your working knowledge of Python functions from the ground up. Each one is a Jupyter notebook — read it in the browser, or open it in the Lab to run and edit the code yourself.

The tutorials build on each other, so working through them in order is the fastest path. Each takes roughly fifteen to twenty minutes.

The sequence

  1. Defining functionsdef, parameters, return values, default arguments.
  2. Lambda expressions — concise anonymous functions.
  3. Type hints — annotating function signatures for clarity and tooling.
  4. Docstrings — documenting functions effectively.
  5. Scope and closures — how Python resolves names, and how closures capture state.
  6. *args and **kwargs — handling variable numbers of arguments.
  7. Decorators — creating and applying decorators.

Before you start

You'll get more from these if you're already comfortable with Python variables, strings, numbers, and if/else. If any of that feels shaky, the Conditional logic and Data structures guides are a good warm-up.

You don't need Python installed locally — every tutorial runs in the Lab. If you'd rather run them on your own machine, each notebook has a download button in the top-right corner.