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
*argsto collect additional positional arguments. - Explain that
*argsstores collected arguments in a tuple. - Iterate through values received through
*args. - Use
**kwargsto collect additional keyword arguments. - Explain that
**kwargsstores collected arguments in a dictionary. - Access and process keys and values received through
**kwargs. - Combine standard parameters, default parameters,
*args, and**kwargsin 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
globalkeyword to modify a global variable from inside a function. - Explain the risks associated with excessive use of global variables.