PCEP Practice Question: Functions, Tuples, Dictionaries and Exceptions
What is the output of the following code?
def greet(name, greeting='Hello'):
print(greeting, name)greet('Alice')
⚠ Common exam trap
Python Institute often tests whether candidates understand that default parameters are used when the corresponding argument is omitted, leading to the misconception that only the default value is printed or that a syntax error occurs.
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
✓
Hello Alice
The function `greet` has a default parameter `greeting='Hello'`. When called with only one argument (`'Alice'`), the default value is used for `greeting`, so the output is `Hello Alice`. The `print` function outputs both arguments separated by a space.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Hello
Why it's wrong here
Incorrect; the name 'Alice' is also printed.
- ✓
Hello Alice
Why this is correct
Correct because the default greeting is used.
- ✗
SyntaxError
Why it's wrong here
No syntax error; the code is valid.
- ✗
Alice
Why it's wrong here
Incorrect; the greeting is missing.
Go deeper
Related to this question
About these practice questions
This PCEP question is part of Courseiva's 498-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. 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.