45 lines
2.0 KiB
Markdown
45 lines
2.0 KiB
Markdown
# Python — reference material
|
|
|
|
This folder is a self-paced Python primer. It is **not** the spine of the class — your project is. We've put it here because some projects will need a working understanding of Python (or another language), and when that comes up it's useful to have something concrete to point at.
|
|
|
|
## When to dip in
|
|
|
|
- Your project genuinely needs you to read or modify Python code, and AI explanations alone aren't sticking.
|
|
- You're curious how the code AI generates for you actually works.
|
|
- You want a foundation so you can steer AI more confidently.
|
|
|
|
## When *not* to dip in
|
|
|
|
- Out of a sense of obligation. There's no test. Nobody is going to ask if you finished `08_classes.py`.
|
|
- Before you have a problem to apply it to. These lessons are dense if you're reading them in the abstract; they click much faster when you have a concrete reason to care.
|
|
|
|
## How to run a script
|
|
|
|
All scripts are standalone. From this folder:
|
|
|
|
```bash
|
|
python3 01_hello_world.py
|
|
```
|
|
|
|
(Use `python` instead of `python3` on Windows if that's what your install named.)
|
|
|
|
## Lessons
|
|
|
|
Work in order if you're starting from zero. Skip around if you already know parts of this.
|
|
|
|
| File | Topic |
|
|
|------|-------|
|
|
| `01_hello_world.py` | `print()` — your first program |
|
|
| `02_variables.py` | Variables, f-strings |
|
|
| `03_datatypes.py` | int, float, str, bool, None; type conversion |
|
|
| `04_conditionals.py` | `if`, `elif`, `else`; comparisons; logical operators |
|
|
| `05_loops.py` | `for`, `while`, `break`, `continue`, `range()` |
|
|
| `06_functions.py` | Defining and calling functions; parameters; return values |
|
|
| `07_lists_and_dicts.py` | Core data structures; list comprehensions |
|
|
| `08_classes.py` | Objects, attributes, methods, inheritance |
|
|
| `09_error_handling.py` | `try`/`except`; raising exceptions |
|
|
| `10_file_io.py` | Reading and writing text and CSV files |
|
|
| `11_putting_it_together.py` | A complete CLI program combining everything |
|
|
|
|
If Python isn't installed yet, see [`installing-python.md`](installing-python.md).
|