Python Cheat Sheets

One-page summaries you can scan in seconds. Every cheat sheet links to the full lesson for each idea, so you can dive deeper when something is unclear.

Core Python

Python Cheat Sheet (Python 3.13 Quick Reference)
This Python cheat sheet puts the most-used syntax for Python 3.13 into tables of tested one-liners: numbers, operators, strings, …
Python String Cheat Sheet: Methods and Formatting
Python strings are immutable text: use slicing to cut them, methods such as `upper()`, `strip()`, `split()` and `replace()` to tr…
Python List Cheat Sheet: Methods and Examples
A Python list is an ordered, changeable collection: add with `append()`, `extend()` and `insert()`, remove with `remove()`, `pop(…
Python Dictionary Cheat Sheet: Methods and Examples
A Python dictionary maps unique keys to values: read with `d[key]` or `d.get(key, default)`, add with `d[key] = value` or `update…
Python Control Flow Cheat Sheet: if, for, while, match
Python control flow uses `if`/`elif`/`else` to choose, `for` and `while` to repeat, `break` and `continue` to steer loops, and `m…
Python Functions Cheat Sheet: def, args, lambda, scope
Define a Python function with `def name(parameters):` and `return` a result; use default values, `*args` and `**kwargs` for flexi…
Python OOP Cheat Sheet: Classes, Inheritance, Dunder Methods
In Python OOP you define a `class` as a blueprint, build objects with it, store data in attributes set in `__init__`, share behav…
Python Regex Cheat Sheet (re Module Quick Reference)
Python regular expressions live in the `re` module: write the pattern as a raw string, then use `re.search()`, `re.findall()`, `r…
Python File Handling Cheat Sheet: open, read, write, CSV, JSON
Open files with `with open(path, mode, encoding="utf-8") as f:` so they close automatically, read with `read()`, `readlines()` or…

Data tools

Python NumPy Cheat Sheet
NumPy stores numbers in fixed-type arrays and applies operations to every element at once: build with `np.array`, `np.arange` or …
Python pandas Cheat Sheet
pandas works on tables: select with `df["col"]`, `df.loc[...]` and `df[df["score"] > 70]`, clean with `fillna` and `dropna`, summ…

Explore more

Python ReferencePython ProgramsPython ComparisonsPython How-To GuidesPython glossaryPython tutorial