Review

Review the path from familiar code through definition, argument binding, fresh local work, returned value, independent test, and documented interface.

From Familiar Code to One Definition

A function gives a connected group of instructions a meaningful name. Python records the definition when execution reaches def; the indented body runs only when execution later reaches a call such as show_summary().

The definition must run before the call. Parentheses distinguish calling the function from merely referring to its name.

From an Argument to a Returned Result

In the definition header def mean(readings):, readings is a parameter.

In mean([18, 22]), the list is an argument. For that call, its value binds to the local parameter. Local total and count change as the loop runs. The returned result crosses back to the caller; the local working names do not.

Printing and returning serve different purposes. print() displays text for a reader. return provides a value that the caller can store, compare, format, or print. Reaching the end without an explicit return produces None.

The mean function also returns None when no available reading exists. That result is deliberate, not an accidental missing return.

One Fresh Call at a Time

Each call receives a fresh set of local names:

The second call begins again with total = 0 and count = 0. It does not continue the first call’s state. Explicit parameters show what enters; a return statement shows what leaves.

Clear Calls and Independent Checks

format_mean(value, unit="°C") requires a value and supplies a common unit by default. A caller may replace it positionally or make the role explicit:

format_mean(68.9, unit="°F")

Tests compare actual results with answers reasoned out independently:

A passing test is evidence for the checked case, not proof for every possible input.

The Complete Interface

familiar code → function definition → argument binding → local work
              → returned value → independent test → documented interface

Meaningful names and concise docstrings state the behavior a caller may rely on. Comments belong inside the implementation only when they explain a reason that the code itself does not make clear.

Pause and reflect

What can you now explain without looking back, and what should you revisit? The note stays with this review.

Review

Not marked done.