The Python Beginner Book

A free, read-in-order introduction to Python for complete beginners. Start at Chapter 1 and work straight through, or jump to a part you need. Each chapter explains one idea with plenty of examples, ends with a small exercise, and links to deeper reference pages when you want more detail.

No setup needed to read. When you’re ready to write code, Part 1 (Start here) shows you how to install Python and run your first program.

Start reading: What Is Python? A Beginner-Friendly Introduction →
  1. Part 1 Start here

    What Python is, why it's worth learning, and getting your first program running.

    1. 1 What Is Python? A Beginner-Friendly Introduction 7 min
    2. 2 Why Learn Python? Use Cases and Benefits 8 min
    3. 3 How to Install Python on Windows, macOS, and Linux 7 min
    4. 4 How to Run Python Code (Command Line and IDEs) 8 min
    5. 5 Your First Python Program: Hello World Explained 5 min
  2. Part 2 Foundations

    The basic rules of how Python code is written and read.

    1. 6 Python Syntax Basics Explained 7 min
    2. 7 Understanding Python Statements and Expressions 7 min
    3. 8 Python Comments Explained (Single-Line and Multi-Line) 7 min
    4. 9 Python Indentation Rules and Why They Matter 6 min
    5. 10 Python Keywords Explained (Beginner Guide) 7 min
  3. Part 3 Variables and types

    Storing data and the basic kinds of values Python works with.

    1. 11 Python Variables Explained for Beginners 7 min
    2. 12 Python Data Types Overview 7 min
    3. 13 Python Numbers Explained (int, float, complex) 6 min
    4. 14 Python Strings Explained (Basics and Examples) 7 min
    5. 15 Python Booleans Explained (True and False) 6 min
    6. 16 Type Conversion in Python (Casting Between Types) 7 min
  4. Part 4 Collections

    Grouping many values together with lists, tuples, sets, and dictionaries.

    1. 17 Python Lists Explained (Beginner Guide) 7 min
    2. 18 Python Tuples Explained 7 min
    3. 19 Python Sets Explained 7 min
    4. 20 Python Dictionaries Explained 7 min
    5. 21 Mutability in Python Explained (Mutable vs Immutable Types) 8 min
    6. 22 When to Use Lists vs Tuples vs Sets vs Dictionaries 8 min
  5. Part 5 Control flow

    Making decisions and repeating work so programs can react and loop.

    1. 23 Python if Statements Explained 6 min
    2. 24 Python if-else and elif Explained 7 min
    3. 25 Python for Loops Explained 7 min
    4. 26 Python while Loops Explained 7 min
    5. 27 Python break and continue Statements 7 min
    6. 28 Python pass Statement Explained 5 min
  6. Part 6 Functions

    Packaging code into reusable, named blocks that take input and return results.

    1. 29 Python Functions Explained 7 min
    2. 30 Function Parameters and Arguments in Python 7 min
    3. 31 Return Values in Python Functions 6 min
    4. 32 Default and Keyword Arguments Explained 6 min
    5. 33 Lambda Functions in Python Explained 6 min
  7. Part 7 Errors and exceptions

    Understanding error messages and handling them so programs don't just crash.

    1. 34 Python Errors and Exceptions Explained 8 min
    2. 35 Using try, except, else, and finally in Python 8 min
    3. 36 Raising Exceptions in Python 7 min
  8. Part 8 Files, modules, and packages

    Reading and writing files, and splitting code across modules you can import.

    1. 37 Python File Handling Basics (Read and Write) 7 min
    2. 38 Working with File Paths in Python 6 min
    3. 39 Python Modules Explained 6 min
    4. 40 How Import Works in Python 8 min
  9. Part 9 Object-oriented programming

    Modelling things as objects with their own data and behaviour.

    1. 41 Python Classes and Objects Explained 7 min
    2. 42 The __init__ Method in Python Explained 7 min
    3. 43 Basic Methods in Python Classes Explained 7 min
    4. 44 Instance vs Class Variables in Python 7 min
    5. 45 Object-Oriented Programming in Python Explained 7 min
  10. Part 10 Going further

    Powerful, slightly more advanced tools once the basics feel comfortable.

    1. 46 List Comprehensions in Python Explained 7 min
    2. 47 Dictionary Comprehensions Explained 8 min
    3. 48 Iterators and Iterable Objects Explained 7 min
    4. 49 Generators in Python Explained 6 min
    5. 50 Decorators in Python (Beginner Introduction) 7 min

Press Esc to close