Learn Python

A structured guide to Python, from your first program to data structures, functions, exceptions, files, and classes, with examples you can run.

Start learning Python

Welcome

Start with what Python is, how to install it, and how to run your first program.

Python Basics

Learn how Python reads code, names values, and stores numbers, text, and truth values.

Operators

See how Python calculates, compares, and combines values, and how is and in differ from ==.

Strings

Work with text: string methods, slicing, and f-strings for formatting.

Control Flow

Choose paths with if and match, and repeat work with for and while loops.

Data Structures

Store groups of values in lists, tuples, dictionaries, and sets, and build them with comprehensions.

Functions

Define functions, pass arguments, return values, and understand scope and recursion.

Errors & Exceptions

Read Python's error messages, handle exceptions, and raise your own.