Level 0 / Project 15 - Level 0 Mini Toolkit¶
Home: README
Learn Your Way¶
| Read | Build | Watch | Test | Review | Visualize | Try |
|---|---|---|---|---|---|---|
| Concept | This project | Walkthrough | Quiz | Flashcards | Diagram | Browser |
Estimated time: 30 minutes
Focus¶
- combine basics into one tiny utility
Why this project exists¶
Combine everything from Level 0 into one multi-tool CLI. Choose between word counting, duplicate detection, and string cleaning -- all in a single script. This capstone shows how small functions compose into larger programs.
Run (copy/paste)¶
Use <repo-root> as the folder containing this repository's README.md.
cd <repo-root>/projects/level-0/15-level0-mini-toolkit
python project.py --input data/sample_input.txt --tool all
pytest -q
Expected terminal output¶
=== Mini Toolkit (all) ===
[wordcount] 5 lines, 18 words
[duplicates] 2 duplicate lines found
[clean] 5 lines cleaned
Output written to data/output.json
5 passed
Expected artifacts¶
data/output.json- Passing tests
- Updated
notes.md
Checkpoint: Baseline code runs and all tests pass. Commit your work before continuing.
Alter it (required) — Extension¶
- Add a fourth tool: "reverse" that reverses the order of lines in the file.
- Add an
--allflag that runs every tool and combines results into one report. - Re-run script and tests.
Break it (required) — Core¶
- Pass
--tool unknown_tool-- doesrun_tool()raiseValueErrorwith a helpful message? - Use an empty file as input -- do all three tools handle it without crashing?
- Pass no
--toolflag at all -- what is the default behaviour?
Fix it (required) — Core¶
- Ensure
run_tool()raisesValueErrorlisting the valid tool names. - Handle empty-file input gracefully for each tool (return zero counts, empty list, unchanged string).
- Add a test for the unknown-tool error message.
Checkpoint: All modifications done, tests still pass. Good time to review your changes.
Explain it (teach-back)¶
- Why does
run_tool()use an if/elif chain instead of a dict mapping tool names to functions? - What does
run_all_tools()demonstrate about combining small functions into larger workflows? - Why is the
--toolargument achoiceslist in argparse? - Where would multi-tool CLIs appear in real software (git, docker, kubectl)?
Mastery check¶
You can move on when you can: - run baseline without docs, - explain one core function line-by-line, - break and recover in one session, - keep tests passing after your change.
Related Concepts¶
| ← Prev | Home | Next → |
|---|---|---|