Introduction
Python in Practice
From the first script to the production API, in three levels, with integrative projects and one executable file per chapter.
Who is this material for
I organized these notes into six parts. The first prepares the machine. The next three follow the progression I use when teaching or when integrating someone into a team: first the language, then the code that others can maintain, and finally what supports a production system. The fifth takes this to a real backend, and the sixth brings everything together in three projects that you build from start to finish.
| Part | For whom | What you will be able to do by the end |
|---|---|---|
| Environment | Who will install Python today, on any system | Install versions, create isolated environments, and choose between pip, pipx, Poetry, and uv |
| Basic | Who is starting or needs to consolidate the basics | Write correct scripts with functions, data structures, exceptions, files, and modules |
| Intermediate | Who already writes scripts and wants to write team code | Model with classes, use generators and decorators, type, test, log, and create a CLI |
| Advanced | Who maintains code in production | Master the data model, concurrency, performance, packaging, and automated quality |
| Backend | Who will build services | Consume and design REST APIs, use FastAPI, PostgreSQL, SQLAlchemy, Alembic, Docker, and observability |
| Projects | Who wants to prove they have learned | Deliver three complete projects, one per level, with tests and automatic checks |
If you have never programmed, start with the Environment part and follow the order. If you already program in another language, read the environment chapters and the mutability and identity chapter, and then jump to where you feel a gap. The projects in the last part indicate, in each one, after which chapter to do them.
How each chapter works
Every chapter follows the same design: a short explanation, a code snippet, and, when the code prints something, its actual output. Each code block shows, at the top, the file and the lines of the repository where it is located. This way, you never have to guess where the code you just read is.
Three details that make a difference:
- The output is real. I executed each chapter and copied what Python printed. When the result depends on your machine (version, path, system), the block states that it is an example.
- The exercises have solutions. Try first. The solution is hidden and ends with
assert, so you find out for yourself if you got it right. - The tabs remember your system. In the installation instructions, choose macOS, Windows, or Linux once and the course switches all the tabs at once.
How to run the code
The repository has a folder for each part and a file for each chapter, named capNN_assunto.py.
python-notes/
README.md
pyproject.toml
docs/
python-notes.html
ambiente/
cap01_como_executa.py
...
basico/
cap09_variaveis.py
...
intermediario/
cap26_classes.py
...
avancado/
cap42_modelo_dados.py
...
backend/
cap52_http_apis.py
...
projetos/
despesas/
tarefas/
processador/
exemplos/
api_pedidos/
pacote/
uv/
Each file runs alone, from the root of the repository:
python3 basico/cap09_variaveis.py
On Windows, replace python3 with py. When you have uv installed (chapter 7), the shortest way is uv run basico/cap09_variaveis.py.
Some files require your participation
Chapters that use
input()expect you to type. Those that write files create these files in the folder where you executed the command, and the.gitignoreof the repository already ignores them. The concurrency chapters use multiple processes and therefore protect execution withif __name__ == "__main__".
Which version of Python does this course assume
The minimum is Python 3.12. When I wrote this, the latest stable series was 3.14, and 3.15 was scheduled for early October 2026. Python 3.10 reaches the end of support in October 2026, which is why I do not use anything below 3.12.
When a feature depends on a version, the text states which one. Examples: match (3.10), tomllib (3.11), TaskGroup and except* (3.11), the syntax class Pilha[T] (3.12) and the lazy evaluation of annotations (3.14).
How I recommend studying
Type the code instead of copying. Run it. Then break it on purpose: change a type, delete a parenthesis, pass an unexpected value and read the error message carefully. Those who learn to read traceback learn Python twice as fast.
Use the sidebar search (the key / opens the field) to return to a topic without scrolling the entire page.