Part 1 · Section 05

Function Parameters

Calling a function looks simple, but Python has a surprisingly rich set of rules for deciding which value ends up in which parameter. Once you understand those rules, signatures like print(*args, sep=' ', end='\n') or def wrapper(*args, **kwargs) stop looking like magic, and you can design functions that are both flexible and hard to misuse.

The key insight of this section is that passing arguments is a lot like unpacking an iterable: values are matched to names by position, and a starred name can collect “the rest”. Keyword arguments, keyword-only parameters and **kwargs build on top of that.

In this section you’ll learn:

Lectures

  1. 01Positional Arguments✓
  2. 02Unpacking Iterables✓
  3. 03Extended Unpacking✓
  4. 04Star-Args✓
  5. 05Keyword Arguments✓
  6. 06Kwargs✓
  7. 07Putting it all Together✓
  8. 08Simple Function Timer✓
  9. 09Parameter Defaults - Beware✓
  10. 10Parameter Defaults - Beware Again✓

Practice: quiz & exercises

15 quiz questions · 4 coding exercises

Go to practice →