Optional beginner guide: run, preserve and rerun

Return to Unit 1 · Choose a unit

This companion reduces file/terminal friction. It adds no assessed task or new scientific result. The original learner, key and measurement function remain unchanged. Use only an existing suitable Python 3 installation; if one is unavailable, keep using labelled paper traces. No account, installation or online interpreter is required. The optional companion download does not provide Python.

1. Keep the supplied files together

In a folder you own, preserve the original measurement_report.py and test_measurement_report.py. Save practice_runner.py beside them as a plain-text file, not a word-processing document. Ensure the actual name ends in .py, not .py.txt. Do not overwrite another file to make room. You can use your editor's “Save As” to keep a separately named practice copy.

Open a terminal in that folder. A terminal accepts commands such as the ones below. If you instead see Python's >>> prompt, leave the interpreter with exit() before entering a terminal command. An editor's own Python runner can also work, but record what you used and its working folder. These instructions do not assume a particular app or operating-system menu.

2. Check the existing interpreter

Try the command already used on your computer, for example:

python3 --version

On a Windows system with the Python launcher, the existing command may instead be:

py --version

Record the exact command and returned version. Do not keep trying commands or install software merely to satisfy this exercise. “Command not found” means that command is unavailable in this terminal; it does not prove Python is absent everywhere. If you cannot identify an existing suitable interpreter, record the limitation and use the conceptual route. The author's Python 3.12.14 result is not your environment record.

3. Establish the original baseline

With the two original files unchanged, run:

python3 measurement_report.py
python3 -m unittest -v test_measurement_report

Use py in both commands if that is your verified existing command. The worked script should print 80 mL, 140 observed seconds, 200 scheduled seconds and the 4/7 rate shown in the learner. The current supplied suite has 16 named tests. Record actual output, errors and exit status when your terminal exposes it. Expected text in the learner is not evidence that your command ran.

4. Run a small separate input

The companion practice_runner.py contains:

from measurement_report import summarise_windows

MY_ROWS = [
    {'id': 'N1', 'elapsed_s': 5, 'volume_ml': 2},
    {'id': 'N2', 'elapsed_s': 5, 'volume_ml': None},
]

result = summarise_windows(MY_ROWS)
print(result)

The first line imports the already supplied function from the neighbouring source file. It is not a package installation or network request. This arrangement reuses the original function rather than duplicating and accidentally altering it. Do not name the runner measurement_report.py, because that would replace the file it needs to import.

Predict its result before running python3 practice_runner.py: observed ID N1, missing N2, 2 mL, 5 observed seconds, 10 scheduled seconds and 0.4 mL/s. The last line displays a dictionary containing these named fields. The zero-volume and missing rules are unchanged.

For your own later task, save a separately named copy of this runner, change only the records in MY_ROWS, and run that copy by its filename. Keep the original input and a short change note. Do not copy expected outputs into the code. The provided 16-test suite checks the original function's contract; it does not automatically check every new dataset you type. Compare new output with your own hand-derived expectations and add appropriate tests.

5. Rerun and record honestly

Run the same saved runner a second time without editing it. Preserve both actual outputs with the version, command, input/source identities and your prediction. A useful record separates “predicted,” “executed output” and “interpretation.” If an import fails, check that the two files are together and correctly named before changing code. If a contract error appears, inspect the affected input and keep the failure record. Never delete an inconvenient row just to get a successful run.

The demonstration has no randomness or external input. Matching reruns show a repeatable computation under those conditions; they do not establish real measurement accuracy, missing-data validity or a functioning website execution service. Actual accessible execution on your device remains a separate requirement.