🧪 Examples
24 Python examples, runnable in your browser
Each snippet runs in a real CPython environment (Pyodide). No install, no signup. Click any card to open the full playground with that snippet pre-loaded.
Hello, World!
Confirm Python is running. Smallest possible example.
List comprehensions
The one-liner that makes Python feel like Python.
pandas in 12 lines
Load, filter, group, aggregate. No CSV download needed.
Plot with matplotlib
Headless matplotlib via Pyodide — figure renders inline in the output panel.
Linear regression with numpy
Fit a line to noisy data in 5 lines.
Call a real HTTP API
Fetch GitHub's API with requests. Auto-installed via micropip.
asyncio in action
Run three coroutines concurrently with asyncio.gather.
Dataclasses + descriptors
Real validation without writing __init__ by hand.
Regex extraction
Pull structured data out of messy text.
CSV read + write
Pure-stdlib CSV with DictReader / DictWriter. No pandas needed.
JSON parse + serialise
json.loads, json.dumps, custom default for dataclasses.
Generators + lazy eval
Memory-friendly streaming with yield and generator expressions.
Custom context managers
with-statement support via class + via @contextmanager decorator.
Exception patterns
Custom exception hierarchy, EAFP, exception chaining.
Modern type hints
PEP 604 union types, TypedDict, Protocol — what mypy expects in 2026.
itertools tricks
groupby, accumulate, pairwise, combinations — the lazy toolkit.
Decorators — log + cache + retry
Real-world decorator patterns: logging wrapper, functools.cache, retry on failure.
SQLite from stdlib
Real database (in-memory) — no install. Create, insert, query, parameterise.
f-string mini-cookbook
Padding, alignment, thousand separators, dates, debug syntax.
dict patterns
Default values, dict comprehensions, dict union (|), nested gets.
pandas — clean a messy CSV
Real cleaning: parse dates, strip whitespace, fill missing, dedupe.
numpy — toy blur kernel
Convolve a 1-D signal with a moving-average kernel.
regex — find + replace
Capture groups in re.sub callbacks. Slugify a string.
OOP — properties + validation
@property + @setter pattern for invariant-protected attributes.
Want a blank canvas? Open the empty playground — full CPython runtime, Cmd/Ctrl + Enter to run, ↗ Share to copy a URL with embedded code.