Question 165 of 510
Functions, Tuples, Dictionaries and ExceptionseasyMultiple ChoiceObjective-mapped

PCEP Practice Question: Functions, Tuples, Dictionaries and Exceptions

This PCEP practice question tests your understanding of functions, tuples, dictionaries and exceptions. The scenario asks you to isolate a root cause — eliminate options that address a different problem before choosing. After answering, compare your reasoning against the explanation and wrong-answer breakdown below. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.

A developer writes a function that should return the sum of two numbers, but the code returns 0 instead. What is the most likely cause?

def add(a, b):

result = a + b

print(add(3, 4))

Clue words in this question

Noticing these words before you look at the options changes how you read each choice.

  • Clue: "most likely"

    Why it matters: Probability qualifier — the question wants the most probable cause or outcome, not a guaranteed one. Eliminate low-probability options.

Question 1easymultiple choice
Full question →

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 function does not have a return statement.

Option D is correct because the function `add` computes `a + b` and assigns it to `result`, but lacks a `return` statement. In Python, a function without an explicit `return` automatically returns `None`. When `print(add(3, 4))` is executed, it prints `None`, not the sum. The question states the code returns 0, which is a common misreading — the actual output is `None`, but the core issue is the missing `return`.

Key principle: Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

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 function is not defined before the call.

    Why it's wrong here

    The function is defined before the print statement.

  • The variable 'result' is not defined.

    Why it's wrong here

    The variable is defined and assigned inside the function.

  • The function parameters are of incompatible types.

    Why it's wrong here

    Both parameters are integers, no type conflict.

  • The function does not have a return statement.

    Why this is correct

    The function computes the sum but does not return it, returning None instead.

    Clue confirmation

    The clue word "most likely" in the question point toward this answer.

    Related concept

    Read the scenario before looking for a memorised answer.

Common exam traps

Common exam trap: answer the scenario, not the keyword

Python Institute often tests the distinction between computing a value inside a function and actually returning it — the trap here is that candidates see `result = a + b` and assume the sum is automatically output, missing the critical absence of the `return` statement.

Detailed technical explanation

How to think about this question

In Python, every function returns a value; if no `return` statement is executed, the function implicitly returns `None`. The `return` statement not only sends a value back to the caller but also immediately exits the function. A common subtlety is that assigning a value to a variable inside a function (like `result = a + b`) does not make that value available outside the function unless it is explicitly returned. In real-world code, forgetting `return` is a frequent bug, especially in data processing pipelines where intermediate results are computed but not propagated.

KKey Concepts to Remember

  • Read the scenario before looking for a memorised answer.
  • Find the constraint that changes the correct option.
  • Eliminate answers that are true in general but not in this case.

TExam Day Tips

  • Watch for words such as best, first, most likely and least administrative effort.
  • Review why wrong options are wrong, not only why the correct option is correct.

Key takeaway

Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Real-world example

How this comes up in practice

A small business has 20 workstations on the 192.168.1.0/24 network and one public IP from its ISP. The router uses PAT (NAT overload) so all 20 devices share one public address using different source ports. NAT questions test whether you understand the four address terms and which direction each translation applies.

What to study next

Got this wrong? Here's your next step.

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

Related practice questions

Related PCEP practice-question pages

Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.

Practice this exam

Start a free PCEP practice session

Short sessions build daily habit. Longer sessions build exam-day stamina. Try a timed session to simulate real conditions.

FAQ

Questions learners often ask

What does this PCEP question test?

Functions, Tuples, Dictionaries and Exceptions — This question tests Functions, Tuples, Dictionaries and Exceptions — Read the scenario before looking for a memorised answer..

What is the correct answer to this question?

The correct answer is: The function does not have a return statement. — Option D is correct because the function `add` computes `a + b` and assigns it to `result`, but lacks a `return` statement. In Python, a function without an explicit `return` automatically returns `None`. When `print(add(3, 4))` is executed, it prints `None`, not the sum. The question states the code returns 0, which is a common misreading — the actual output is `None`, but the core issue is the missing `return`.

What should I do if I get this PCEP question wrong?

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

Are there clue words in this question I should notice?

Yes — watch for: "most likely". Probability qualifier — the question wants the most probable cause or outcome, not a guaranteed one. Eliminate low-probability options.

What is the key concept behind this question?

Read the scenario before looking for a memorised answer.

About these practice questions

Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Last reviewed: Jun 30, 2026

Question Discussion

Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.

Loading comments…

Sign in to join the discussion.

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.