Courseiva

PCEP Practice Question: Functions, Tuples, Dictionaries and Exceptions

A developer defines a function with the signature def configure(host, port=8080, protocol='http'). A call is made as configure('web01', protocol='https'). Which statement describes what happens?

⚠ Common exam trap

The trap here is thinking keyword arguments are matched to parameters by their left-to-right position in the call rather than by their explicit names.

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

✓

The call succeeds; host receives 'web01', port keeps its default 8080, and protocol receives 'https'.

Positional arguments bind to parameters in order, while keyword arguments bind by name regardless of position. Here the single positional value fills host, the keyword protocol fills that named parameter, and port is simply omitted, so it retains its default. The call is valid and produces host='web01', port=8080, protocol='https'.

Answer analysis

Option-by-option breakdown

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

  • ✗

    The call fails with a SyntaxError because default parameters must always be passed explicitly when any keyword argument is used.

    Why it's wrong here

    Default parameter values exist precisely so callers may omit those arguments. There is no rule requiring defaults to be passed whenever a keyword argument appears. The call is syntactically valid and semantically correct: host gets 'web01', port stays 8080, and protocol becomes 'https'. No SyntaxError or TypeError is produced by this invocation.

  • ✓

    The call succeeds; host receives 'web01', port keeps its default 8080, and protocol receives 'https'.

    Why this is correct

    Positional arguments fill parameters left to right, so 'web01' binds to host. The keyword argument protocol='https' binds by name, skipping port, which therefore retains its default value of 8080. Python allows mixing positional and keyword arguments as long as no parameter receives two values and no required parameter is missing, so this call is valid and behaves exactly as described.

  • ✗

    The call fails with a TypeError because a positional argument cannot be combined with a keyword argument.

    Why it's wrong here

    Mixing positional and keyword arguments is explicitly permitted in Python. The restriction is that positional arguments must come first and that no argument may be supplied twice. Since 'web01' is positional and protocol='https' is a distinct keyword, there is no conflict, so no TypeError is raised and the call proceeds normally.

  • ✗

    The call succeeds, but 'https' is assigned to port because keyword arguments fill parameters in declaration order.

    Why it's wrong here

    Keyword arguments are matched by parameter name, not by declaration order. The name protocol in the call maps directly to the protocol parameter, so port is never given the value 'https'. It keeps its default 8080. Assuming order-based binding for keywords misunderstands how Python resolves keyword arguments against the function's parameter names.

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.