One page

Python cheat sheet

What to keep at hand. If a line is not clear, go back to the matching lesson in the course.

Open the course: Python: getting started

Syntax

WhatHow
Blocka colon + an indent
EmptyNone
Stringf"n={n}"
Comment#

Data and functions

WhatHow
List["tea", "coffee"]
Dict{"id": 1}
Loopfor x in xs:
Functiondef greet(name):
Classclass User:
Filewith open(...) as f:

Other cheat sheets