All tutorials
Python tutorial
The friendliest place to start. Short, readable code that runs as soon as you write it.
- 01Your first Python programWhat Python is, how to run a program, printing to the screen, comments, and how to read an error message without panic.8 min
- 02Variables and data typesStoring values in variables, the four basic types (int, float, str, bool), checking a type, and converting between them.9 min
- 03Operators and expressionsArithmetic including the three kinds of division, comparisons, and, or and not, shorthand assignment, and the order Python works things out in.9 min
- 04Strings, formatting and inputIndexing and slicing text, the string methods you will use every day, f-strings for formatting, and reading input with input().11 min
- 05Making decisions with if, elif and elseRunning code only when something is true, chaining choices with elif, what Python counts as true, and the one-line conditional expression.8 min
- 06Loops with for and whileRepeating work with for and range, looping until something happens with while, stopping early with break and continue, and enumerate for position and value together.10 min
- 07FunctionsDefining functions with def, parameters and return values, default and keyword arguments, where variables live, and why small named functions make code easier.10 min
- 08Lists and tuplesCreating, reading and changing lists, adding and removing items, sorting, list comprehensions, two-dimensional lists and the classic trap, and when to use a tuple.12 min