Skip to main content
By the end of this module you can do everything below. The objectives and their wording come from the official PCEP-30-03 syllabus.

4.1.4 Accept variable numbers of arguments

  • Use *args to collect additional positional arguments.
  • Explain that *args stores collected arguments in a tuple.
  • Iterate through values received through *args.
  • Use **kwargs to collect additional keyword arguments.
  • Explain that **kwargs stores collected arguments in a dictionary.
  • Access and process keys and values received through **kwargs.
  • Combine standard parameters, default parameters, *args, and **kwargs in a valid function definition.

4.1.5 Manage variable scope

  • Distinguish between local and global name scopes.
  • Explain how names created inside a function are resolved.
  • Recognize namespaces and variable shadowing.
  • Use the global keyword to modify a global variable from inside a function.
  • Explain the risks associated with excessive use of global variables.