{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "576a9320",
   "metadata": {},
   "source": [
    "# Tooling \n",
    "\n",
    "This appendix is a **tooling reference** for the whole book. You do not need to master everything here before moving on — read it once for orientation, then return to specific sections as you need them in later chapters.\n",
    "\n",
    "**What this appendix covers**\n",
    "\n",
    "| Notebook | Topic | When you'll need it |\n",
    "|---|---|---|\n",
    "| 5.1 — Files | Reading/writing files; `Path()` | Anytime you load or save data |\n",
    "| 5.2 — Modules | Writing and importing your own `.py` modules | When your code outgrows a single notebook |\n",
    "| 5.3 — Packaging | Package structure; `pip`; `requirements.txt`; virtual envs | When sharing or deploying a project |\n",
    "| 5.4 — Coding Tooling | List comprehensions; lambda; docstrings; type hints; `enumerate`/`zip`; `try/except`; f-string formatting | Throughout — these are everyday Python idioms |\n",
    "\n",
    "**How to use this appendix**\n",
    "\n",
    "- Browse 5.1–5.3 early so you know what's available.\n",
    "- Treat 5.4 as a recipe book: look up a pattern when you encounter it in later chapters.\n",
    "- Treat this appendix as a reference: use it when a later chapter expects one of these practical patterns."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "31e6723c",
   "metadata": {},
   "source": [
    "<h2>What is a Module?</h2>\n",
    "\n",
    "Python organizes reusable code in three levels:\n",
    "\n",
    "```\n",
    "function        → one reusable operation             def square(x): ...\n",
    "module          → one .py file of related functions  math_tools.py\n",
    "package         → a folder of related modules        my_package/\n",
    "```\n",
    "\n",
    "The standard library ships hundreds of modules. You have already used several:\n",
    "\n",
    "| Module | What you used it for |\n",
    "|---|---|\n",
    "| `math` | `math.sqrt()`, `math.pi` |\n",
    "| `random` | `random.choice()`, `random.randint()` |\n",
    "| `pathlib` | `Path()` for file paths |\n",
    "| `time` | `time.perf_counter()` for benchmarking |\n",
    "\n",
    "In 5.2 you will write your own module. In 5.3 you will learn how to install modules others have written.\n",
    "\n",
    "<h2>Importing Patterns</h2>\n",
    "\n",
    "```python\n",
    "import math                        # import the whole module; access via math.sqrt()\n",
    "from math import sqrt              # import one name; access as sqrt()\n",
    "from math import sqrt, pi         # import multiple names\n",
    "from math import sqrt as sq        # import with an alias\n",
    "import math as m                   # rename the module itself\n",
    "```\n",
    "\n",
    "Prefer `import module` over `from module import *` — the star import pollutes the namespace and makes it hard to tell where a name came from."
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
