SigmaAnalytics & Tech
A11PythonBeginnerAbout 140 min to complete

Functions

The ability to write code that stays readable, testable, and reusable as it grows past 50 lines.

Notebook

About 140 minutes to complete

Enrol to read the notebook and download it to run.

What this module covers

The ability to write code that stays readable, testable, and reusable as it grows past 50 lines.

By the end of it

  • Define functions with clear names, parameters, and return values
  • Write professional docstrings that make a function usable without reading its body
  • Distinguish parameters from arguments, and positional from keyword passing
  • Use default parameters — and avoid the mutable default argument bug
  • Accept variable arguments with args and *kwargs
  • Enforce keyword-only parameters with * for safer APIs
  • Explain the LEGB scope rule and use global/nonlocal correctly (and rarely)
  • Predict whether a function can modify its arguments, using Notebook 04's memory model