Interactive course
Python Course
Learn Python from scratch, in English, with CPython compiled to WebAssembly: your code runs directly in the browser.
01 · Language basics
The foundations: declaring variables, recognizing types, doing arithmetic, making decisions and printing to the console.
- 1.1Variables and typesGive a name to a value, discover the type with type(), get to know int / float / str / bool / None.~10 min
- 1.2OperatorsArithmetic (including // and **), comparison, boolean logic with and / or / not, precedence.~10 min
- 1.3Conditionals: if, elif, elseRun different code depending on a condition; the role of indentation.~10 min
- 1.4Printing and f-stringsprint() to show values, f-strings to compose text with `{var}` interpolation.~8 min
02 · Control flow
Repeat, jump, handle errors: the constructs that make the program react to data and problems.
- 2.1for loops and rangeIterate over a sequence with for, generate numeric ranges with range(start, stop, step).~10 min
- 2.2while loopsRepeat while a condition holds; when to prefer while over for.~8 min
- 2.3break, continue and else in loopsExit a loop early, skip an iteration, use the peculiar for…else.~10 min
- 2.4Error handling: try/exceptCatch specific exceptions, tell try/except/else/finally apart, raise errors with raise.~12 min
03 · Data structures
The four built-in collections: list (mutable sequence), tuple (immutable sequence), dict (key-value map) and set (collection of unique elements).
- 3.1ListsCreate, access by index and slice, add and remove, sort. The sequence you will use the most.~12 min
- 3.2Tuples and unpackingImmutable sequences, packing and unpacking, swap without a temporary variable, * for the rest.~10 min
- 3.3Dictionarieskey→value maps, access with [] and .get, iterate over keys/values/items, dict.setdefault.~12 min
- 3.4SetsCollections of unique elements, set operations (& | - ^), O(1) membership test.~10 min
04 · Strings and numbers
Work with text (methods, slicing) and numbers (math, type conversions) idiomatically.
- 4.1String methodsThe most-used methods: upper/lower, strip, split/join, replace, startswith/endswith, find/in.~12 min
- 4.2Slicing and indexingPositive and negative indices, slice [start:stop:step], string reversal, substrings.~10 min
- 4.3Numbers and the math moduleint, float, true vs integer division, % modulo, abs/round/min/max, math.sqrt, math.pi.~10 min
- 4.4Type conversionsint(), float(), str(), bool(): explicit casting, input parsing, truthiness of values.~10 min
05 · Functions
Define functions with def, return values, manage default parameters, *args/**kwargs and lambda.
- 5.1def and returndef syntax, return (explicit and implicit None), positional parameters, docstring.~12 min
- 5.2Default and keyword parametersDefault values, calls with keyword arguments, positional-before-keyword order, mutable default pitfall.~12 min
- 5.3*args and **kwargsVariable-argument functions: *args collects positional, **kwargs collects keyword. Unpack at call site.~12 min
- 5.4Lambda and higher-order functionsAnonymous functions with lambda, use with sorted/max/min, when to prefer def, sorted(..., key=...).~10 min
06 · Comprehensions and iteration
List/dict/set comprehensions, generator expressions and the fundamental tools of the itertools module.
- 6.1List comprehensionSyntax [expression for x in iter if cond], transformation, filtering, nested.~12 min
- 6.2Dict and set comprehensionSyntax {k: v for ...} and {x for ...} to build dicts and sets declaratively.~10 min
- 6.3Generator expressionSyntax (... for ... in ...), lazy iteration, constant memory, sum/any/all on generators.~10 min
- 6.4Essential itertoolsThe most-used functions: enumerate, zip, chain, count, repeat, combinations.~12 min
07 · Classes and modules
Object-oriented programming in Python: classes, inheritance, special methods (dunder), import and module organization.
- 7.1Classes and instancesclass, __init__, instance attributes and methods, self, class vs instance attributes.~14 min
- 7.2InheritanceSubclasses, super(), method override, isinstance, basic MRO.~12 min
- 7.3Special methods (dunder)__str__, __repr__, __eq__, __len__: integrate your objects with the language.~12 min
- 7.4import and modulesimport, from ... import, alias as, module organization, if __name__ == "__main__".~10 min
08 · Essential standard library
The standard library modules you will meet every day: json, datetime, collections, re.
- 8.1JSON: serialize and parsejson.dumps / json.loads, Python ↔ JSON type mapping, indent, sort_keys, default.~10 min
- 8.2datetime: dates and timesdatetime.now(), date/time/datetime/timedelta, formatting with strftime, parsing with strptime, arithmetic.~12 min
- 8.3collections: Counter and defaultdictCounter for counting, defaultdict for auto-initialized dicts, namedtuple as a lightweight record.~12 min
- 8.4re module: regex in Pythonre.search / re.match / re.findall / re.sub, flags, raw strings r"...", named groups.~12 min
09 · Modern Python: practice
Modern Python practices: type hints, dataclass, context managers and decorators. The code you write in 2025.
- 9.1Type hints: annotating typesAnnotations on parameters and return, list[int] / dict[str, int], Optional, Union, a note on mypy.~12 min
- 9.2dataclass: data classes without boilerplate@dataclass, field(default_factory=...), frozen=True, equivalent of __init__/__repr__/__eq__.~12 min
- 9.3Context manager: with and __enter__/__exit__with open(...), writing your own context manager with __enter__/__exit__, contextlib.contextmanager.~12 min
- 9.4Decorators: functions that modify functionsHigher-order functions, @decorator syntax, functools.wraps, @timeit example.~14 min