Free resources
Free SQL and Python Cheat Sheets (PDF)
Two printable references for developers preparing for interviews or building with GenAI: a free SQL interview cheat sheet PDF and a free Python cheat sheet PDF. Preview every page in your browser before you download. Each PDF comes in a light version for printing and a dark version for screens.
SQL Interview Cheat Sheet
The SQL that interviews test — from SELECT and joins to window functions and 15 classic problems. Every query was run on a sample database, and its real result table is printed underneath. Each example is labelled with the databases it runs on (SQLite, PostgreSQL, MySQL, SQL Server).
Prefer dark mode? Download the dark version · SQL cheat sheet details
Complete Python Cheat Sheet
A complete Python reference in 11 parts — from fundamentals to OOP, concurrency, testing and GenAI apps. Examples show their real output and were run on Python 3.12; features that need a newer Python version are marked.
Prefer dark mode? Download the dark version · Python cheat sheet details
What's inside each cheat sheet¶
Both contents lists below are copied from page 1 of the PDFs.
SQL Interview Cheat Sheet: 8 parts, 11 pages¶
The SQL cheat sheet uses one small company database (shown on page 2). Each query is followed by the table it actually returns when run on SQLite 3.45. Each example is labelled with the databases it runs on unchanged. The MySQL, PostgreSQL and SQL Server equivalents are on page 11.
| Part | What it covers | Page |
|---|---|---|
| 1. Basics | SELECT, WHERE, NULL traps, CASE, text and date functions, pagination | 3 |
| 2. Aggregation | COUNT/SUM/AVG, GROUP BY, HAVING, conditional aggregation, UNION | 4 |
| 3. Joins | inner, left, right, full, cross, self, anti- and semi-joins, pitfalls | 5 |
| 4. Subqueries & CTEs | scalar, IN, EXISTS, correlated, the NOT IN trap, recursive CTEs | 6 |
| 5. Window functions | ROW_NUMBER, RANK, DENSE_RANK, LAG/LEAD, running totals, frames | 7 |
| 6. Changing data | INSERT, UPDATE, UPSERT, constraints, indexes, transactions, ACID | 8 |
| 7. 15 classic interview problems | Nth salary, duplicates, streaks, median, pivot, month-over-month change | 9–10 |
| 8. Concepts & answers | keys, normalisation, performance, dialect table, quick answers | 11 |
Complete Python Cheat Sheet: 11 parts, 17 pages¶
Code examples show their real output in comments. They were run on Python 3.12.7, and anything that needs Python 3.10 or newer is marked. Parts 1–8 use only the standard library, plus pytest in Part 8. The page 1 box lists the packages needed for Parts 9–10.
| Part | What it covers | Pages |
|---|---|---|
| 1. Core Python | types, numbers, strings, f-strings, conditions, match, loops, functions, scope | 2–3 |
| 2. Data structures | list, tuple, set, dict, copying, comprehensions, sorting, collections, itertools, Big-O | 4–5 |
| 3. Object-oriented Python | classes, properties, inheritance, MRO, ABCs, magic methods, dataclasses, enums | 6–7 |
| 4. Advanced functions | iterators, generators, decorators, closures, functools, context managers | 8 |
| 5. Errors, logging & files | exceptions, chaining, exception groups, logging, pathlib, CSV, JSON | 9 |
| 6. Standard library | regex, datetime, time zones, os, subprocess, argparse, random, math | 10 |
| 7. Concurrency | GIL, threads, locks, processes, asyncio, TaskGroup, timeouts | 11 |
| 8. Typing, tooling & testing | type hints, generics, pyproject, project layout, debugging, pytest, mocks | 12–13 |
| 9. Data & web | NumPy, pandas, charts, HTTP, FastAPI, Pydantic, SQLite | 14–15 |
| 10. Python for GenAI | LLM calls, structured output, tokens and cost, chunking, embeddings, RAG | 16 |
| 11. Interview prep | memory model, gotchas, quick answers, complexity reference | 17 |
How to use them for interview prep¶
- Predict before you read. Learn the sample tables on page 2 of the SQL sheet. Then, for each query, guess the result before you look at the printed output.
- Write the query yourself first. Cover the solution to each of the 15 interview problems, write your own answer, then compare. Explain your approach out loud as you go.
- Run the Python examples. Each example shows its real output, so if your result differs, you've found something to revisit.
- Finish with the checklists. Each sheet ends with an interview revision checklist: section 8.6 in the SQL sheet and section 11.5 in the Python sheet.
Related free tutorials and notes¶
These free pages on this site go deeper into the topics the cheat sheets cover.
Python notes and tutorials
- Python basics for GenAI: variables, data structures, functions and classes
- Advanced Python: generators, decorators, async, type hints and testing
- Testing Python code with pytest: fixtures, parametrize and mocks
- async and await in Python, explained in plain English
- How to read a Python error message (traceback) and fix it
- Common coding mistakes in Python and GenAI projects
SQL-style data work in Python
- Pandas filtering: the pandas version of SQL WHERE and ORDER BY
- Pandas groupby and aggregation: the pandas version of SQL GROUP BY
- Pandas merge, concat and pivot: SQL-style joins and reshaping
Interview prep and projects
- RAG interview questions with model answers
- Build a RAG chatbot over your documents in Python, step by step
Previewing and downloading
- Preview first. Preview PDF shows the whole document in your browser — no email needed. On phones, or if your browser can't show PDFs, it opens in a new tab instead.
- Free. Enter your email once and the PDF downloads straight away; we'll occasionally send you new free resources — unsubscribe any time (Privacy Policy).
- Light and dark. The light version prints well on A4; the dark version is easier on screens.
- Share it. You may share the PDFs unchanged with credit; they're not for resale (Terms).
Want more? Browse all free Python for GenAI notes and step-by-step GenAI tutorials, or see what's coming in the Store.





