Functions & Scope · Question 3 · Easy

In Python, what value does a function give back when its body ends without executing any return statement?

  1. 0
  2. An empty string
  3. It raises a SyntaxError
  4. None
Answer and explanation

Answer: D. None

Explanation: Every Python function returns something. If no return statement runs, the function returns the special object None.

Previous: The greet function below prints a message but has no return statement. What… · Next: A lambda is given a default value for its second parameter. What does this…

Practise functions & scope

Try a fresh set of functions & scope questions with an explanation after every answer, free and without signing up: Functions & Scope practice. Or sit a full placement mock test.

More functions & scope questions

More python practice

Comprehensions & Generators · Classes & Objects · Exceptions & Files · Built-ins & Standard Library · Variables, Types & Operators · Python Strings · Lists & Tuples · Dictionaries & Sets

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge