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 can be specified in any order after positional arguments.
- ✓
Using **kwargs allows passing a variable number of keyword arguments.
Why this is correct
**kwargs collects extra keyword arguments into a dictionary.
- ✗
The *args parameter must always come after **kwargs in a function definition.
Why it's wrong here
*args must come before **kwargs.
- ✓
Using *args in a function definition allows passing a variable number of positional arguments.
Why this is correct
*args collects extra positional arguments into a tuple.
- ✓
Default arguments are evaluated once when the function is defined, not each time it is called.
Why this is correct
Default values are evaluated at definition time.
Go deeper
Related to this question
About these practice questions
Courseiva writes every PCEP question from scratch — 498 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.