Courseiva

PCEP Computer Programming and Python Fundamentals Practice Question

A developer defines a function and calls it as shown:

def greet(name, greeting='Hello'):
    return greeting + ', ' + name

print(greet('Ana'))

What is printed?

⚠ Common exam trap

The trap here is forgetting that an omitted argument silently uses the parameter's default rather than causing an error or leaving the placeholder empty.

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, Ana

Default parameter values let a caller omit arguments that have sensible fallbacks. Because greet is invoked with only 'Ana', that value binds to name while greeting uses its default 'Hello'. The concatenation then yields the string 'Hello, Ana', which is printed to the console.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    A TypeError is raised.

    Why it's wrong here

    A TypeError would occur if a required parameter were missing during the call. Here name is supplied positionally and greeting has a default, so every parameter receives a value. Concatenating two strings with + is valid, so the call completes normally and returns a string instead of raising an exception.

  • ✓

    Hello, Ana

    Why this is correct

    The parameter greeting has a default value of 'Hello'. When greet is called with only the positional argument 'Ana', name receives that value and greeting falls back to its default. The function concatenates the two strings with a comma and space, producing 'Hello, Ana', which print then displays.

  • ✗

    Hello, greeting

    Why it's wrong here

    This would only appear if the literal parameter name were used as the value, which does not happen in Python. The identifier greeting is a variable holding the string 'Hello', and name holds 'Ana'. The function substitutes the actual values bound to those names, so the output contains the name passed in, not the identifier text.

  • ✗

    Ana, Hello

    Why it's wrong here

    The return expression places greeting first and name second, so the default greeting appears before the supplied name. Reversing them would require swapping the operands in the concatenation. As written, the function always prepends the greeting string, so the output cannot begin with the name argument.

About these practice questions

This PCEP question is part of Courseiva's 482-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 →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Python Institute exam blueprint

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.