PCEP Keyword arguments Practice Question
Which of the following statements about function arguments are true? (Select all that apply)
⚠ Common exam trap
A common pitfall in the PCEP exam is the order of *args and **kwargs: *args must precede **kwargs. Also, candidates often incorrectly think default arguments are evaluated each call, but they are evaluated once at definition time.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Keyword arguments can be passed in any order, regardless of their position in the function definition.
The correct statements are A, B, D, and E. Keyword arguments can be passed in any order because they are matched by name (A). The **kwargs parameter collects additional keyword arguments into a dictionary (B). The *args parameter collects additional positional arguments into a tuple (D). Default arguments are evaluated once at function definition time (E). Option C is incorrect because *args must always appear before **kwargs in a function definition.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Keyword arguments can be passed in any order, regardless of their position in the function definition.
Why this is correct
Keyword arguments bind by parameter name rather than position, so the caller may supply them in any sequence and Python still maps each value to the matching parameter. This satisfies the stem's requirement that ordering is irrelevant, unlike positional arguments, which must follow the definition's sequence exactly.
- ✓
Using **kwargs allows passing a variable number of keyword arguments.
Why this is correct
**kwargs collects any number of keyword arguments into a dictionary inside the function, so callers may supply arbitrarily many named arguments without a fixed signature. This directly satisfies the stem's requirement for a true statement about function arguments, since Python permits zero or more keyword arguments to be gathered this way.
- ✗
The *args parameter must always come after **kwargs in a function definition.
Why it's wrong here
The order is the reverse: *args must precede **kwargs, because positional parameters cannot follow keyword-collecting ones. It is tempting because both collect variable arguments and appear interchangeable, but Python's parameter ordering rules fix *args before **kwargs, so the stated sequence is invalid syntax.
- ✓
Using *args in a function definition allows passing a variable number of positional arguments.
Why this is correct
Using *args in a function definition collects extra positional arguments into a tuple, so callers may supply any number of them without a TypeError. This directly satisfies the stem's requirement for a true statement about function arguments, since it describes variadic positional parameter handling rather than keyword arguments.
- ✓
Default arguments are evaluated once when the function is defined, not each time it is called.
Why this is correct
Python binds default argument values at function definition time, storing them in the function object. Mutable defaults therefore persist across calls, which is why this statement is true and why mutable defaults are a common pitfall.
Go deeper
Related to this question
About these practice questions
Courseiva writes every PCEP question from scratch — 482 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
Same concept, more angles
1 more way this is tested on PCEP
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. A programmer wants to create a function that can accept any number of keyword arguments and store them in a dictionary. Which function definition is correct?
hard- A.def func(kwargs):
- ✓ B.def func(**kwargs):
- C.def func(**args):
- D.def func(*kwargs):
Why B: The **kwargs parameter in a function definition collects any number of extra keyword arguments into a dictionary. The double asterisk (**) is the Python syntax for capturing keyword arguments, and 'kwargs' is the conventional name for the resulting dictionary.
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This PCEP practice question is part of Courseiva's free Python Institute certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCEP exam.