Functions and return values
def creates a function object with named parameters. Calling it binds arguments and executes the body; return passes a result to the caller. Printing is an observable side effect and is not the same as returning a value. A function that reaches its end without return produces None. def classify(value): return "warning" if value>=80 else "normal" lets tests inspect the result without capturing terminal output or depending on a printed label. Clear return values make logic reusable in scripts, tests and APIs and separate computation from presentation so callers can choose how to display, store or act on the result in their own context. Replacing return with print changes the function’s contract to None and can break downstream comparisons; use printing only when the function’s explicit responsibility is presentation rather than calculation for other callers.
def classify(value): return "warning" if value>=80 else "normal" lets tests inspect the result without capturing terminal output or depending on a printed label.
Clear return values make logic reusable in scripts, tests and APIs and separate computation from presentation so callers can choose how to display, store or act on the result in their own context.
Replacing return with print changes the function’s contract to None and can break downstream comparisons; use printing only when the function’s explicit responsibility is presentation rather than calculation for other callers.