Python Parameters and Arguments
Objective 4.2 is organise interaction between the function and its environment, and the argument side of it is the most rule-heavy part of PCEP. There are three ways to pass a value and two ways to collect extra ones; there are four different errors an argument list can produce, two of them at compile time; and there is one default value that behaves in a way nobody expects until they have seen it happen.
Functions and Scope Guide 19 of 26 Intermediate
- OSUbuntu 26.04 LTS
- Python3.14.4
- pip25.1.1
- TimeAbout 19 min
Positional-only parameters (/) arrived in Python 3.8 and keyword-only parameters (*) in 3.0. Neither is on the PCEP syllabus and neither appears here. Everything on this page has been true since Python 3.0.
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| RUNNER01 | 192.168.0.27 | Ubuntu 26.04 LTS | Python 3.14.4 - the only machine this path needs | 2 Core | 4 GB | 50 GB |
This guide includes
Use this for the argument half of the function objective, the most rule-bound material on PCEP. This matters because a default value is computed once, when the def runs - so a mutable default is shared by every call that follows.
- using the words the questions use precisely, parameter against argument
- collecting the rest with
*argsand**kwargs - meeting three ways a call is rejected at run time, and two before anything runs
- finding the default that is evaluated once, and the fix
- learning what a function can and cannot change about its caller
Before you start
- guide 18 - the first half of the function material.
- guide 14 - the mutable default step depends on aliasing.
-
The words, because questions use them precisely
-
Collecting the rest: *args and **kwargs
-
Three ways a call is rejected at run time
-
Two ways a call is rejected before anything runs
-
The default that is evaluated once
-
The fix, and why it is written that way
-
What a function can and cannot change about its caller
-
What the exam does with this objective