A function’s return value lets another part of a Python program use its result. Printing a value and returning it serve different purposes.
Worked example
A function that doubles a score can return the number to its caller. The caller can then add a bonus, compare the result with a target, or display it. A function that only prints the doubled score writes text to the screen but, without an explicit return statement, returns None to its caller.
What to check
Test the result of calling the function directly. If the next calculation receives None, check whether the function returned the computed value. Keep the calculation separate from user input and display when possible. That separation lets you test several scores without typing answers each time. Include a zero score and a typical positive score, then compare the returned values with the expected arithmetic.
Continue with the book
Explore the full treatment, worked examples, and exercises in Code Quest with Python.
Companion article for Code Quest with Python, published by Choral Software. Article text and original examples © 2026 Choral Software. All rights reserved.
