# Python: make it run

These files are original LearnAI teaching material (CC0). They require Python 3.10 or later and only its standard library. No AI service is called.

1. Install Python 3 from your operating system's package manager or the official Python installer if it is missing. On Windows enable the installer's PATH option. You may need an administrator or school technician. Do not install packages or run commands you do not understand.
2. Extract the ZIP into a new folder. Open Terminal/PowerShell there (on Windows, right-click the folder and choose Open in Terminal). A terminal accepts commands; a Python file contains the program. Do not paste shell commands into the `>>>` Python prompt: enter `exit()` first.
3. Run `python --version`. If Windows provides `py` instead, substitute `py` for `python` below; on macOS/Linux it may be `python3`.
4. Run `python workshop.py`. The two rows have subtotal 14 credits. Edit a copy in a text editor, save, then rerun. Keep `.py` as the extension, not `.py.txt`.
5. Run `python -m unittest test_workshop.py`. These supplied implementation checks should pass. Run `python -m unittest test_learner.py` to see the intentional TODO failures, then implement `learner.delivery_total` and add tests. Default discovery runs both sets and will fail until the exercise is complete.

If a file is not found, check the current folder and extracted filenames. If indentation fails, use four spaces consistently. Read the final traceback line for the immediate error, then the referenced source line. Do not delete tests or change expected values to match a bug.

## Read the worked program

```python
orders = [[2, 3], [4, 2]]  # each row: quantity, credits per item
first_quantity = orders[0][0]  # index zero is first
first_price = orders[0][1]
first_total = first_quantity * first_price
```

`def` starts a function. Parameters name inputs; `return` supplies output. `if` chooses a branch; `for row in rows` repeats work for each row. Indentation groups statements. `raise ValueError(...)` rejects invalid input. Type checks reject booleans even though Python permits them in some arithmetic. No NumPy arrays are required: nested lists make rows and columns visible.

## Four lesson exercises

- Values: change the first row to `[5, 4]`; predict the new subtotal before running. Compare number `3 + 2` with text `"3" + "2"` in a small file.
- Functions: implement `delivery_total`. Validate the fee; add it once for a nonempty list, never once per row. Empty lists cost zero.
- Debugging: preserve your first failed test output. Add a counterexample for a plausible wrong implementation. Explain why `(2,2)` fails to distinguish addition from multiplication.
- Tables: try a missing price, text price and negative quantity. Reject malformed rows rather than dropping them. Shape alone does not validate units.

## Reproducible Program project

Use the separate project brief on the course page: new rows, discount boundary, one-time delivery and output packaging are required. Implement the extension yourself; an unchanged supplied run is not the project. Retain inputs, SHA-256 (using `hashlib`), configuration, Python/code version, tests, raw reports and a README with exact commands. Open new outputs with mode `x` to avoid overwriting prior evidence. Do not put personal data in the pack.

Run the scientific comparison starter supplied in the shared reproducibility module as well. Explain its fitting/monitoring boundary and include its reproduction instructions; matching output alone does not validate a scientific conclusion.

Ask a reviewer to run your package from a fresh folder, change one input and ask you to explain the result and one repair. Public checks and a completion flag do not establish independent programming proficiency.
