Python Functions

positional, keyword, defaults, args and *kwargs

35 min · interactive lesson with runnable code and 6 graded exercises.

What you'll be able to do

  • Match arguments by position and by name
  • Avoid the mutable-default-argument bug
  • Explain args (tuple) and kwargs (dict) — and unpack with / **
  • Use keyword-only parameters with a bare *

The full lesson is free with an account.

Positional & keyword

Default arguments

*args and **kwargs

How arguments bind

Putting it together

Common pitfalls