PCEP Computer Programming and Python Fundamentals Practice Question
A function is defined as:
def add(a, b=5):
return a + bWhat is the result of add(10)?
⚠ Common exam trap
Python Institute often tests the misconception that default parameters are required or that omitting them causes an error, leading candidates to pick 'Error' (option D) when the function is actually called correctly with a single argument.
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
✓
15
The function `add(a, b=5)` defines a default value of 5 for parameter `b`. When called as `add(10)`, the argument 10 is assigned to `a`, and `b` uses its default value of 5. The function returns `10 + 5 = 15`, making option C correct.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
10
Why it's wrong here
The function returns a + b, so add(10) evaluates 10 + 5 = 15; returning 10 would require b to default to 0. It is tempting because 10 is the supplied argument, and it would be correct if the function simply returned its first parameter unchanged.
- ✗
5
Why it's wrong here
The return statement adds both parameters, so add(10) yields 15, not the default value 5 alone. Returning 5 is tempting because b defaults to 5, and it would be correct if the function returned only b, or if a were omitted entirely.
- ✓
15
Why this is correct
The parameter b uses its default value of 5 because only one argument is supplied, so the call evaluates 10 + 5, returning 15. Python applies default arguments when the corresponding positional argument is omitted.
- ✗
Error
Why it's wrong here
Python supplies the default b=5 when the second argument is omitted, so add(10) returns 15 without raising any exception. The error expectation is tempting because missing arguments normally raise TypeError, which would be correct if b had no default value assigned.
Go deeper
Related to this question
About these practice questions
One of 482 original PCEP practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
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.