Practice mode Python

What does a Python function return if it finishes without executing a return statement?

Correct answer D. None

Explanation

Every Python function returns a value. If execution falls off the end of the body, or a bare return is used, the function returns None. Python does not return the value of the last expression as some languages such as Ruby do, so print(f()) shows None.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.