nerdexam
Python_Institute

PCEP-30-02 · Question #161

What is the default return value for a function that does not explicitly return any value?

The correct answer is D. None. In Python, when a function reaches its end without an explicit return statement, the interpreter automatically returns None - Python's built-in null/empty value representing the absence of a result. Why the distractors are wrong: A (void) - void is a keyword in statically-typed…

Question

What is the default return value for a function that does not explicitly return any value?

Options

  • Avoid
  • BNull
  • Cpublic
  • DNone
  • Eint

How the community answered

(24 responses)
  • A
    4% (1)
  • C
    17% (4)
  • D
    71% (17)
  • E
    8% (2)

Explanation

In Python, when a function reaches its end without an explicit return statement, the interpreter automatically returns None - Python's built-in null/empty value representing the absence of a result.

Why the distractors are wrong:

  • A (void) - void is a keyword in statically-typed languages like C, C++, and Java to declare that a function returns nothing; it doesn't exist in Python.
  • B (Null) - Null (capitalized) is not a Python keyword; it's used in languages like Java (null) or SQL. Python uses None, not Null.
  • C (public) - public is an access modifier from Java/C++; it has nothing to do with return values and doesn't exist in Python.
  • E (int) - int is a data type, not a return value; no language automatically returns a zero integer from a function with no return statement.

Memory tip: Think "No return → None" - in Python, absence of an explicit return always gives you None, which you can verify by printing the result of any function that lacks a return statement.

Community Discussion

No community discussion yet for this question.

Full PCEP-30-02 Practice