Free Python Books: Legally Free Python Programming Books, Beginner to Advanced
A curated list of free Python books you can read legally online or download from the author or publisher, from absolute beginner to advanced topics like architecture, testing, data science and CPython internals. Every entry says what the book is best for, its level and its license, so you can pick the right free Python book instead of scrolling a giant link dump.
Last reviewed: December 2026. “Free” means free to read online or download from an official source (author site, publisher, university, open license) at the time of review. Many of these books are also sold in print; buying a copy is a good way to thank the authors.
Table of Contents
- Quick Picks
- What Counts as Legally Free
- Reading Paths with Time Estimates
- Level 1: Absolute Beginner
- Level 1b: Learn Python by Making Games and Puzzles
- Level 2: Computer Science with Python
- Level 3: Intermediate and Idiomatic Python
- Level 4: Testing, Architecture and Professional Practice
- Data Science, Statistics and Scientific Python
- Web Development with Python
- Python Internals and the Language Itself
- Official Documentation Worth Reading Like a Book
- Free Courses That Pair Well with the Books
- Excellent Paid Books (Clearly Marked)
- Books We Deliberately Left Out
- Comparison: Which Beginner Book Should You Choose
- Practice Projects to Do Alongside the Books
- How to Actually Finish a Programming Book
- FAQ
- Where to Go Next
- Contributing
- License
Quick Picks
If you only read one section, read this one.
| You are… | Best free pick | Why |
|---|---|---|
| New to programming, want practical results fast | Automate the Boring Stuff with Python, 3rd ed. | Every chapter ends with something useful: renaming files, scraping pages, editing spreadsheets and PDFs. |
| New to programming, want solid fundamentals | Think Python, 3rd ed. | Short, careful, teaches how to think about programs; each chapter is a runnable Jupyter notebook. |
| A student, want a structured course text | Python for Everybody | Pairs with free lectures, autograded exercises and a whole course site. |
| Already code in another language | The Python Tutorial | The official tour; you can finish it in a weekend. |
| Want CS foundations, not just syntax | Composing Programs | The text behind a famous intro CS course; functions, abstraction, recursion, interpreters. |
| Intermediate, want “Pythonic” code | Beyond the Basic Stuff with Python | Style, tooling, common gotchas, OOP, and how to grow from scripts to programs. |
| Building real apps | Architecture Patterns with Python | Domain modeling, repository, unit of work, events, with tests. |
| Learning TDD and web testing | Test-Driven Development with Python, 3rd ed. | Builds a Django app test-first, from the first line to deployment. |
| Going into data | Python for Data Analysis, 3rd ed. | Written by the creator of pandas; covers pandas 2 and NumPy. |
What Counts as Legally Free
This list only includes books that the author, publisher or institution deliberately made free. In practice that means one of these:
- Open license - Creative Commons (CC BY, CC BY-SA, CC BY-NC-SA and so on) or similar. You can read, share and often adapt the text within the license terms.
- Free to read online, all rights reserved - the author hosts the full text for free but keeps copyright. You can read it; you should not re-upload it.
- Pay what you want, with $0 allowed - for example some Leanpub or Gumroad books. We say so when that is the case.
We never link to “free PDF download” mirror sites. If a book is only free on a sketchy host, it is not on this list. If you find a book here that is no longer free from its official source, please open an issue.
License shorthand used below:
CC BY-NC-SA- share and adapt for non-commercial use, with attribution, under the same license.CC BY-NC-ND- share for non-commercial use with attribution, no derivatives.Free online- free to read on the official site, normal copyright otherwise.
Reading Paths with Time Estimates
Times assume about 1 hour a day, 5 days a week, and include doing the exercises (which is the point).
Path A: Zero to useful scripts (6 to 10 weeks)
| Week | Read | Do |
|---|---|---|
| 1-2 | Automate the Boring Stuff, Part I (basics) | Type every example; do the practice questions. |
| 3-4 | Automate the Boring Stuff, files, regex, web chapters | Automate one real chore you have (rename photos, clean a CSV). |
| 5-6 | Python Programming Exercises, Gently Explained | Do 3 to 5 exercises a day without looking at answers first. |
| 7-10 | The Big Book of Small Python Projects | Rebuild 10 projects from memory, then change them. |
Path B: Zero to solid fundamentals (10 to 16 weeks)
| Weeks | Read | Do |
|---|---|---|
| 1-4 | Think Python, 3rd ed. | All exercises; it is short, so do not skip any. |
| 5-8 | Composing Programs | Chapters 1-2 thoroughly; implement the examples yourself. |
| 9-12 | Problem Solving with Algorithms and Data Structures | Implement stacks, queues, trees, graphs from scratch. |
| 13-16 | Beyond the Basic Stuff with Python | Set up a linter, formatter and tests on your own project. |
Path C: Programmer from another language (3 to 5 weeks)
| Week | Read | Do |
|---|---|---|
| 1 | The Python Tutorial | Port a small program you have written before. |
| 2 | Practical Python Programming | Work through the exercises in order; they build one program. |
| 3 | Python Mastery | Advanced course: generators, metaprogramming, objects deeply. |
| 4-5 | Architecture Patterns with Python | Apply one pattern to a work-sized project. |
Path D: Python for data (12 to 20 weeks)
| Weeks | Read | Do |
|---|---|---|
| 1-4 | Think Python or Python for Everybody | Basics only; do not wait to feel “ready”. |
| 5-8 | Python for Data Analysis | Load and clean three real public datasets. |
| 9-12 | Python Data Science Handbook | NumPy, pandas, Matplotlib, scikit-learn basics. |
| 13-16 | Think Stats | Answer one question with data and write it up. |
| 17-20 | Learning Data Science | Do a full project: question, data, model, report. |
Level 1: Absolute Beginner
| Book | Author(s) | Best for | License / access |
|---|---|---|---|
| Automate the Boring Stuff with Python, 3rd ed. | Al Sweigart | Complete beginners who want practical automation (files, Excel, PDFs, web, email). The 3rd edition is free to read online. | CC BY-NC-SA 3.0, free online |
| Think Python, 3rd ed. | Allen B. Downey | Fundamentals done carefully; debugging advice in every chapter. Chapters are Jupyter notebooks that run on Colab. (book page) | CC BY-NC-SA 4.0 |
| Python for Everybody | Charles R. Severance | University-style intro with free lectures and exercises at py4e.com. PDF. | CC BY |
| A Byte of Python | Swaroop C H | A very short, friendly first read. Good if long books intimidate you. | CC BY-SA 4.0 |
| How to Think Like a Computer Scientist: Interactive Edition | Runestone Academy contributors | Run code and answer quizzes inside the browser. Great for classrooms. | Free online (open source) |
| Foundations of Python Programming | Runestone Academy contributors | Interactive text used in a well-known university specialization; lots of in-page exercises. | Free online |
| The Python Tutorial | Python Software Foundation | The official, always up to date introduction. Best for people who already know another language. | PSF docs license, free |
| A 100 Page Python Intro | Sundeep Agarwal | Compact intro with exercises for people who want the essentials fast. | Free online |
| Python Programming (Wikibook) | Wikibooks contributors | A reference-ish community book; uneven but broad. Use as a supplement. | CC BY-SA |
| Python Like You Mean It | Ryan Soklaski | Beginner Python aimed at STEM students, with early NumPy. | Free online |
| Problem Solving with Python | Peter D. Kazarinoff | Engineers and scientists learning Python for calculations and plotting. | Free online |
Best pick: Automate the Boring Stuff if motivation is your bottleneck; Think Python if understanding is. Many people read both: Automate first for momentum, Think Python second for depth.
Level 1b: Learn Python by Making Games and Puzzles
Building something playable is the fastest way to make syntax stick. All of these are free to read online at inventwithpython.com.
| Book | Best for | Notes |
|---|---|---|
| Invent Your Own Computer Games with Python | Teens and adults who want text games first | Hangman, Tic-Tac-Toe, Reversi and more, one per chapter. |
| The Big Book of Small Python Projects | Practice after your first book | About 80 short programs (games, simulations, animations), each kept deliberately small. |
| Python Programming Exercises, Gently Explained | Drilling basics | Small exercises with step-by-step explanations; ideal for interview warm-ups. |
| Cracking Codes with Python | People who like puzzles and crypto | Classical ciphers and how to break them; good for loops and strings. |
| Making Games with Python & Pygame | Graphical games | Older Pygame code, but the game logic lessons still apply. |
| Program Arcade Games with Python and Pygame | Classroom-style graphics course | Paul Vincent Craven’s course text with labs and videos. |
| The Recursive Book of Recursion | Finally understanding recursion | Python and JavaScript examples; great before algorithm interviews. |
Level 2: Computer Science with Python
| Book | Author(s) | Best for | License / access |
|---|---|---|---|
| Composing Programs | John DeNero (based on SICP) | Abstraction, higher-order functions, recursion, data abstraction, interpreters. | Free online (Creative Commons) |
| Problem Solving with Algorithms and Data Structures using Python | Brad Miller, David Ranum and others | The standard free DSA text in Python; interactive. | Free online |
| Data Structures and Information Retrieval in Python | Allen B. Downey | DSA through a project (a small search engine). | CC BY-NC-SA |
| Think Complexity, 2nd ed. | Allen B. Downey | Graphs, cellular automata, agent-based models; good “second” CS book. | CC BY-NC-SA |
| Python Programming and Numerical Methods | Qingkai Kong, Timmy Siauw, Alexandre Bayen | Numerical methods for engineers: root finding, ODEs, regression, interpolation. | Free online |
| The Recursive Book of Recursion | Al Sweigart | Recursion and backtracking explained without hand-waving. | Free online |
| Natural Language Processing with Python | Steven Bird, Ewan Klein, Edward Loper | Classic NLTK book; useful for text processing basics (older, pre-LLM). | CC BY-NC-ND 3.0 |
Best pick: Composing Programs for thinking; Problem Solving with Algorithms and Data Structures for interviews.
Level 3: Intermediate and Idiomatic Python
| Book | Author(s) | Best for | License / access |
|---|---|---|---|
| Beyond the Basic Stuff with Python | Al Sweigart | The jump from “I know syntax” to “I write clean, tooled code”: Black, linters, git, naming, OOP, performance basics. | CC BY-NC-SA |
| Practical Python Programming | David Beazley | A complete course text for programmers; data handling, functions, classes, generators, packages. | CC BY-SA 4.0 |
| Python Mastery | David Beazley | Advanced course material: the object model, decorators, metaclasses, coroutines. | CC BY-SA 4.0 |
| Intermediate Python | Muhammad Yasoob Ullah Khalid | Short chapters on *args, decorators, generators, context managers, comprehensions. |
Free online (open source) |
| Python Design Patterns guide | Brandon Rhodes | Which classic patterns actually fit Python, and which are unnecessary in it. | Free online |
| Python 3 Patterns, Recipes and Idioms | Bruce Eckel and contributors | An unfinished but useful community book on idioms and patterns. | Free online |
| The Little Book of Python Anti-Patterns | QuantifiedCode | Short catalog of common mistakes and their fixes. Some items are dated (Python 2 era). | Creative Commons (non-commercial) |
| Understanding Python re(gex)? | Sundeep Agarwal | A whole book on Python’s re module, with exercises. |
Free online |
| Python 3 Module of the Week | Doug Hellmann | Tour of the standard library with examples. Excellent for “is there a built-in for this?” | Free online |
| Pydon’ts | Rodrigo Girão Serrão | Idiomatic Python features explained one at a time. Free download, pay-what-you-want option. | Free download |
| The Hitchhiker’s Guide to Python | Kenneth Reitz and community | Opinionated best practices: project structure, environments, tooling. Parts predate modern tools like uv, so cross-check with the Packaging User Guide. | CC BY-NC-SA 3.0 |
Best pick: Beyond the Basic Stuff for most people; Practical Python Programming if you already program professionally.
Level 4: Testing, Architecture and Professional Practice
| Book | Author(s) | Best for | License / access |
|---|---|---|---|
| Test-Driven Development with Python (“Obey the Testing Goat”), 3rd ed. | Harry Percival | Learning TDD end to end with Django, Selenium and deployment. The 3rd edition adds a preface on TDD in the age of AI. | Free online, CC-licensed |
| Architecture Patterns with Python (“Cosmic Python”) | Harry Percival, Bob Gregory | Domain-driven design, ports and adapters, repository, unit of work, message bus, event-driven microservices. (source) | CC BY-NC-ND (online version) |
| Clean Architectures in Python | Leonardo Giordani | A smaller, gentler take on clean architecture with a full worked example. Also on Leanpub (pay what you want). | Free online |
| Python Packaging User Guide | PyPA | How to structure, build and publish packages correctly. | Free (official) |
| Full Stack Python | Matt Makai | A map of deployment, servers, databases, monitoring for Python web apps. Some pages are older. | Free online |
| pytest documentation | pytest-dev | The de facto test framework; its “how-to” guides read like a short book. | Free |
| Python typing documentation and mypy docs | Python typing council, mypy team | Type hints, generics, protocols, gradual typing. | Free |
Best pick: read Obey the Testing Goat first, then Cosmic Python. Together they cover most of what “senior Python developer” means beyond syntax.
Data Science, Statistics and Scientific Python
| Book | Author(s) | Best for | License / access |
|---|---|---|---|
| Python for Data Analysis, 3rd ed. | Wes McKinney | pandas (updated for pandas 2.0), NumPy, data wrangling. Open access HTML edition. | Free online (code MIT) |
| Python Data Science Handbook | Jake VanderPlas | IPython, NumPy, pandas, Matplotlib, scikit-learn, all as notebooks. (repo) | CC BY-NC-ND 3.0 (text), MIT (code) |
| Think Stats, 3rd ed. | Allen B. Downey | Exploratory data analysis and statistics with code instead of formulas. | Creative Commons |
| Think Bayes, 2nd ed. | Allen B. Downey | Bayesian statistics using simple Python computations. | CC BY-NC-SA |
| Elements of Data Science | Allen B. Downey | Data science for people with no programming background. | CC BY-NC-SA |
| Modeling and Simulation in Python | Allen B. Downey | Physical and population models, differential equations, simulation. | CC BY-NC-SA |
| Computational and Inferential Thinking | Ani Adhikari, John DeNero, David Wagner | The text of a large intro data science course; inference through simulation. | CC BY-NC-ND 4.0 |
| Learning Data Science | Sam Lau, Joseph Gonzalez, Deborah Nolan | Full data science lifecycle: wrangling, visualization, modeling, with case studies. | Free online |
| Scientific Python Lectures | Scientific Python community | NumPy, SciPy, Matplotlib, image processing, optimization, in one tutorial book. | Free online |
| Python Programming for Economics and Finance | QuantEcon (Thomas J. Sargent, John Stachurski) | Python for economists, with an excellent NumPy and performance section. | Free online |
| NumPy: the absolute basics for beginners | NumPy team | The fastest official way into arrays. | Free |
| pandas User Guide | pandas team | Topic-by-topic official guide. | Free |
For machine learning and AI books, see the sister list free-programming-books-ai.
Web Development with Python
| Resource | Best for | Access |
|---|---|---|
| Django Girls Tutorial | Your very first web app: build and deploy a blog. | Free |
| The Flask Mega-Tutorial | A long, serious Flask course: templates, forms, databases, auth, APIs, deployment. Free on the blog; ebook and video course are paid. | Free online |
| FastAPI Tutorial - User Guide | Modern typed APIs with automatic docs. Reads like a book chapter by chapter. | Free (official) |
| Test-Driven Development with Python | Django plus testing done properly. | Free online |
| Full Stack Python | Seeing how all the pieces of a deployed app fit. | Free online |
Python Internals and the Language Itself
| Resource | Best for | Access |
|---|---|---|
| Inside the Python Virtual Machine | How CPython compiles and executes bytecode. Leanpub “pick your price” page shows a free option; last updated 2024. | Free / pay what you want |
| CPython Internals notes (zpoint) | Diagrams of how built-in types are implemented in C. | Free (GitHub) |
| Python Developer’s Guide | Contributing to CPython; also explains the compiler, parser and garbage collector. | Free (official) |
| Python Language Reference and HOWTOs | Deep dives on descriptors, logging, sorting, regex, Unicode, the free-threaded build and more. | Free (official) |
| PEP 8 - Style Guide for Python Code | The style guide everything else references. | Public domain |
Official Documentation Worth Reading Like a Book
- The Python Tutorial - read cover to cover once.
- The Python Standard Library - skim the table of contents so you know what exists:
pathlib,itertools,functools,collections,dataclasses,asyncio,concurrent.futures,sqlite3. - Python HOWTOs - especially the descriptor and functional programming HOWTOs.
- Python Packaging User Guide - packaging,
pyproject.toml, publishing. - uv documentation and Ruff documentation - the fast modern tooling many teams now use for environments, dependencies, linting and formatting.
Free Courses That Pair Well with the Books
| Course | Pairs with | Notes |
|---|---|---|
| CS50’s Introduction to Programming with Python | Think Python or Automate | Free lectures and problem sets; certificate is optional. |
| Python Programming MOOC 2026 (University of Helsinki) | Any beginner book | Hundreds of auto-graded exercises; excellent for practice volume. |
| Python for Everybody course site | Python for Everybody | Lectures, exercises and autograder for the book. |
| Kaggle Learn: Python | Data path | Short, notebook-based, leads into pandas and ML micro-courses. |
| Exercism Python track | Intermediate books | Free practice with optional human mentoring. |
| Python Tutor | Every book | Visualizes your code step by step; perfect when a loop or reference confuses you. |
Excellent Paid Books (Clearly Marked)
These are not free. They are listed so you know what people mean when they recommend them, and so you can decide whether to buy one later.
| Book | Why people recommend it | Status |
|---|---|---|
| Fluent Python, 2nd ed. (Luciano Ramalho) | The best deep dive into the Python data model, iterators, concurrency and metaprogramming. | Paid (companion site is free) |
| Python Crash Course, 3rd ed. (Eric Matthes) | Very popular beginner book with three projects. | Paid |
| Effective Python (Brett Slatkin) | 100-plus specific tips for writing better Python. | Paid (site has free sample code) |
Books We Deliberately Left Out
- Dive Into Python 3 - a classic CC BY-SA book, but the original author’s site is long gone and the domain that now carries its name is full of unrelated gambling ads. It also predates modern Python. We do not link to it.
- “Notes for Professionals” PDF collections - we could not confirm a reliable official host at review time.
- Learn Python the Hard Way - no longer free.
- Any “free PDF” of a paid book found on file-sharing sites. Those are pirated copies.
Comparison: Which Beginner Book Should You Choose
| Automate the Boring Stuff | Think Python | Python for Everybody | A Byte of Python | Python Tutorial | |
|---|---|---|---|---|---|
| Length | Long | Medium | Medium | Short | Short |
| Style | Practical projects | Conceptual, careful | Course-style | Conversational | Reference-like tour |
| Exercises | Practice questions and projects | Many exercises | Exercises plus autograder | Few | Few |
| Best for | Office and hobby automation | Future CS students and engineers | Students who want structure | Fast skim | Experienced programmers |
| Format | HTML | Jupyter / HTML | HTML, PDF | HTML | HTML |
Practice Projects to Do Alongside the Books
Reading without building does not stick. After each stage, build one of these and push it to GitHub.
Beginner (after Level 1)
- A command-line to-do list that saves to a JSON file.
- A file organizer that sorts your Downloads folder by extension.
- A number guessing game, then add difficulty levels and a high-score file.
- A unit converter with input validation.
- A script that reads a CSV of expenses and prints totals by category.
Intermediate (after Level 2-3)
- A web scraper for a page you check every day, saving results to SQLite.
- A text-adventure engine where rooms are defined in a data file.
- Implement a linked list, hash map and binary search tree with tests.
- A Markdown-to-HTML converter for a subset of Markdown.
- A CLI tool with
argparse, packaged withpyproject.tomland installable with pip.
Advanced (after Level 4)
- A small REST API with FastAPI or Flask, tested with pytest, using the repository pattern from Cosmic Python.
- A tiny interpreter for a calculator language (see Composing Programs, chapter 3).
- A data analysis report on a public dataset using pandas, written as a notebook with conclusions.
- An async web crawler with rate limiting and retries.
- Contribute a documentation fix to an open-source Python project.
How to Actually Finish a Programming Book
- Type the code; do not paste it. Typos you make and fix are lessons.
- Do the exercises before reading on. If you skip them, you are reading, not learning.
- Keep a “stuck log”. Write down what confused you and how you solved it.
- Stop at a third of a chapter if you must, but stop after an exercise, so the next session starts with something concrete.
- Pick one book per stage. Switching books when it gets hard feels productive and isn’t.
- Build something small after every 3-4 chapters. It does not have to be original.
- Use Python Tutor when references, mutation or recursion confuse you.
FAQ
What is the best free Python book for beginners? For most people, Automate the Boring Stuff with Python (practical) or Think Python (fundamentals). Both are complete and free from their authors.
Is Automate the Boring Stuff still free in 2026? Yes. The 3rd edition is free to read online at automatetheboringstuff.com under a Creative Commons non-commercial license; print and ebook versions are sold by the publisher.
Can I download free Python books as PDF? Some, yes: Python for Everybody has an official PDF, and Think Python’s source is on GitHub. Others are online-only. If a “PDF download” site offers a book that is paid, it is pirated.
Which Python version should I learn?
Learn current Python 3. All books here use Python 3; avoid anything that shows print "hello" without parentheses (Python 2).
How long does it take to learn Python? Basics in 4-8 weeks at an hour a day. Being comfortable enough for junior work or real data analysis usually takes 4-9 months of steady practice with projects.
Do I need math to learn Python? Not for general programming or automation. Data science and ML need statistics and some linear algebra; Think Stats and Think Bayes teach statistics through code.
Is Python enough to get a job? Python plus one domain (web back end, data, automation, ML) plus git, SQL and testing is a realistic junior profile. See the Where to Go Next section.
What about free Python books for kids? Invent Your Own Computer Games with Python works well for teens. Younger children usually do better with block-based tools first.
Are AI assistants a replacement for books? They are great for explaining an error or a concept, but they work best when you already know enough to judge their answers. A structured book gives you that base.
Where to Go Next
- Algorithms and interviews: solve problems on Exercism and study Problem Solving with Algorithms and Data Structures.
- Machine learning and AI: free-programming-books-ai.
- Another language: free-programming-books-javascript, free-programming-books-go-rust, free-programming-books-cpp, free-programming-books-java.
- The big multilingual index: the community-maintained free-programming-books by the Free Ebook Foundation (searchable site).
- Talks: PyVideo indexes thousands of free Python conference talks.
Contributing
Suggestions are welcome. To add a book, open a pull request or issue with:
- The official URL (author, publisher, university or open-license host - no mirrors).
- The license or access terms, and the edition.
- One sentence on who it is best for.
We remove books that stop being free or whose links break. Please report dead links.
License
This list is released under CC BY 4.0. The books themselves belong to their authors and publishers under their own licenses.
If this helped you, a star helps others find it.
More free resources
Part of the Ralpberry Labs open-source collection. See also Top 100 Open Source.