Chapter 6 · Project and Next Steps
Summary, Cheat Sheet and What's Next
- Page 23 of 23
- 4 min read
What you can do now
- Set up Python with a virtual environment, an editor and pip — or work in a notebook.
- Use Python's core types and collections, make decisions, loop, and write functions and classes.
- Read and write text, JSON, CSV and JSON Lines files, and handle errors properly.
- Work with arrays in NumPy, tables in pandas and charts in Matplotlib.
- Call web APIs and LLMs from Python safely: secret keys, timeouts, retries, validation, async and streaming.
- Write classes with inheritance,
super()and properties, and use iterators, generators and decorators. - Choose data structures and algorithms with Big-O in mind: sets for lookups, binary search, queues, heaps, recursion and caching.
- Organise a project with a package and tests, work in Jupyter notebooks, and train and test a first scikit-learn model.
Cheat sheet
| Task | Python |
|---|---|
| Format text | f"{name} scored {score:.1f}" |
| Loop with position | for i, item in enumerate(items, start=1): |
| Build a filtered list | [x.strip() for x in lines if x.strip()] |
| Read a dict key safely | data.get("key", default) |
| Sort by a field | sorted(rows, key=lambda r: r["score"], reverse=True) |
| Read a file | with open(path, encoding="utf-8") as f: |
| JSON ↔ Python | json.loads(text) / json.dumps(obj, ensure_ascii=False) |
| Catch a specific error | try: … except ValueError as error: … |
| Load a table | df = pd.read_csv("data.csv") |
| Filter and group | df[df["x"] > 5].groupby("col")["y"].mean() |
| Call an API | requests.post(url, json=payload, timeout=10) |
| Call an LLM | client.responses.create(model=MODEL, input=text).output_text |
| Many calls at once | await asyncio.gather(*(task(x) for x in items)) |
| Wrap a function | @wraps(func) inside def decorator(func): … |
| Read-only attribute | @property above def name(self): |
| Split data for ML | train_test_split(X, y, test_size=0.2, random_state=42) |
| Train and test a model | model.fit(X_train, y_train); model.score(X_test, y_test) |
| Fast membership test | banned = set(words) then if w in banned: |
| Top k by score | heapq.nlargest(k, scores.items(), key=lambda p: p[1]) |
| A queue | q = deque(); q.append(x); q.popleft() |
Glossary
| Term | Meaning |
|---|---|
| Variable | A name that refers to a value |
| Function | A named, reusable block of code that can take inputs and return a result |
| Class / object | A blueprint bundling data and methods / one thing made from it |
| Module / package | A Python file you can import / a folder of modules, often installed with pip |
| Virtual environment | A private set of installed packages for one project |
| Exception | An error raised while the program runs, which can be caught and handled |
| JSON | A text format for structured data used by almost every web API |
| Vectorisation | Working on whole arrays at once instead of looping element by element |
| DataFrame | pandas' table of rows and named columns |
| API / SDK | A way for programs to talk to a service / a library that wraps an API in friendly code |
| Embedding | A list of numbers representing the meaning of a text |
| Async | Running many waiting tasks (like API calls) at the same time |
| Iterator / generator | An object that hands out values one at a time with next() / the easy way to write one, with yield |
| Decorator | A function that wraps another function to add behaviour, written as @name |
| Notebook | A document of code cells, outputs and notes, run by a kernel that keeps variables between cells |
| Features / label | The inputs a model looks at / the answer it learns to predict |
| Training / test set | The data a model learns from / the hidden data that shows how it does on new examples |
| Overfitting | Doing well on the training data by memorising it, and worse on new data |
| Big-O | How the work grows with the size of the input: O(1), O(log n), O(n), O(n²) |
| Recursion | A function that solves a problem by calling itself on smaller pieces, stopping at a base case |
Check yourself
Take the four quizzes in order: Easy (after chapter 2, the basics), Medium (after chapter 4, files, classes and data), the Hard final exam (after chapter 5, AI work) and Quiz 3 (after chapter 6: OOP, iterators, decorators, notebooks and machine learning). Read the explanation for every answer you miss, then revisit that page.
What's next
The next topics in the Level 0 path are Maths and Statistics essentials — the vectors, probability and statistics behind machine learning, which you can now explore in NumPy — then SQL and data handling, Git, APIs and basic back-end, and Prompt Engineering.
Above all: build something. Pick a small, real problem — your study notes, your shop's orders, your club's messages — and solve it with the tools from this tutorial. You learn programming by writing programs.