← back to reading list

Python in 5 Minutes

If you already know any programming language, you know most of Python.

Python 3 + 4 infix: operator between Scheme (+ 3 4) prefix: operator first

Variables and expressions

No type declarations. No semicolons. Just assign and compute.

Python

Functions

Define with def. Indentation marks the body. return sends a value back.

Python

Lists

Square brackets make a list. Index from zero. Slice with start:end. len() gives the length.

Python

Conditionals

if, elif, else. Indentation replaces braces.

Python

List comprehensions

Build a new list by transforming and filtering an existing one, all in one line.

Python

Lambda

lambda creates a small anonymous function. Combine with map() and filter() to transform sequences.

Python

Dictionaries

Key-value pairs. Create with dict(), access by key, iterate over items.

Python
That's enough to read every page on this site.