The Complete Python Cheat Sheet — Beginner to Pro

A comprehensive, interactive Python reference covering 26 parts — from Hello World to metaclasses — built by a developer with 20+ years of Python teaching experience. Every section is collapsible and searchable. Every code snippet is runnable in your browser via Pyodide. Includes 30+ "Common Mistake vs. Pythonic Way" comparisons, a live code editor, dark mode, and a streamer mode designed for live coding on YouTube. Covers Python 3.10–3.13 features including structural pattern matching, the walrus operator, and the new union type syntax.

Press / or Cmd+K to search · s Stream Mode · d Dark/Light · ▶ Run to execute code in-browser

0/26 done

Install & Run

Python 3.10+ is recommended. Download from python.org or use a version manager.

Shell
# Check version
python --version   # or python3 --version

# Interactive REPL
python

# Run a script
python hello.py

# Run a module
python -m http.server 8080
💡 Use pyenv (Linux/Mac) or pyenv-win (Windows) to manage multiple Python versions side-by-side.
Package Management
# pip — Python package manager
pip install requests           # install
pip install requests==2.31.0  # specific version
pip install -r requirements.txt
pip list                       # installed packages
pip show requests              # package info
pip uninstall requests

Hello World & Conventions

hello.py
print("Hello, World!")
print("Python", 3.12, "rocks")
name = "Alice"
print(f"Hello, {name}!")
ConventionExampleUsed for
snake_caseuser_name, get_data()Variables, functions, modules
PascalCaseUserProfile, HttpClientClasses
SCREAMING_SNAKEMAX_RETRIES, API_URLConstants
_single_leading_internal_method()Private by convention
__double_leading__slots__Name-mangled class attrs
💡 PEP 8 is the official style guide. Run `pip install ruff` and use `ruff check .` for instant linting.

Virtual Environments

Shell
# Create
python -m venv .venv

# Activate
source .venv/bin/activate      # Linux/Mac
.venv\Scripts\activate       # Windows PowerShell

# Deactivate
deactivate

# Modern alternative: uv (10x faster than pip)
pip install uv
uv venv
uv pip install requests
Common Mistake
✗ Avoid
# Installing packages globally
pip install flask
✓ Pythonic
# Always use a virtual environment
python -m venv .venv && source .venv/bin/activate
pip install flask

Global installs pollute your system Python and cause version conflicts across projects.

Frequently Asked Questions

Is this Python cheat sheet free?

Yes — completely free, forever, with no signup required. Every feature including the live code runner, search, and dark mode works without an account. There are no paywalled sections.

Can I run the code examples in my browser?

Yes. Click the Run button on any code snippet to launch the browser-based Python runtime (powered by Pyodide). The runtime loads on first use (~5–10 seconds on a typical connection) and then all subsequent runs are instant. You can edit the code before running it.

Which version of Python does this cheat sheet cover?

This cheat sheet targets Python 3.10+ as the baseline, with notes on Python 3.12 and 3.13 features. Structural pattern matching (match/case) requires 3.10+. The new X | Y union type syntax for type hints requires 3.10+. Most examples work on Python 3.8+.

Can I use this cheat sheet during a live stream or in a video?

Yes — it includes a Stream Mode toggle designed specifically for YouTube and Twitch live coding. Stream Mode increases font sizes, collapses the navigation sidebar to icon-only, and hides ads to keep the screen clean. The site owner uses this page in their own live streams.

How do I search the cheat sheet quickly?

Press Cmd+K (Mac) or Ctrl+K (Windows) to open the search modal, or press the / key anywhere on the page. Search covers section titles, subsection titles, concept keywords, and code snippet content. Press Esc to close, Arrow keys to navigate results, Enter to jump.

Will this work offline?

The cheat sheet page and all content work offline once initially loaded — the page is fully static with no server dependency. The live code runner requires a one-time download of the Pyodide Python runtime (~10 MB). After that initial download (which browsers cache), code execution works offline.