Python examples.
Simple, readable, powerful.
Python Basics
print, variables, comments, escape sequences, type(), input/output
Python — Starter Programs
Minimal runnable programs to get you started with Python. Admins can add more via the admin panel or the AI bulk-generate button.
Operators & Math
arithmetic, comparison, logical, bitwise, walrus, augmented assignment
Operators & Math
arithmetic, comparison, logical, bitwise, walrus, augmented assignment
Strings
indexing, slicing, f-strings, .format(), methods (upper/lower/split/join/replace/strip), repr
Strings
indexing, slicing, f-strings, .format(), methods (upper/lower/split/join/replace/strip), repr
Lists & Tuples
create, index, slice, append/extend/insert, sort/reverse, comprehensions, unpacking
Dicts & Sets
key access, .get/.setdefault, iteration, dict comprehension, set ops (union/intersection/diff)
Dicts & Sets
key access, .get/.setdefault, iteration, dict comprehension, set ops (union/intersection/diff)
Control Flow
if/elif/else, for, while, range, break/continue, else-on-loop, match (3.10+)
Functions
def, default args, *args/**kwargs, lambda, decorators (basic), recursion, type hints
Classes & OOP
class, __init__, self, dunder methods, inheritance, super, @property, dataclasses
Classes & OOP
class, __init__, self, dunder methods, inheritance, super, @property, dataclasses
File I/O & Modules
open with-block, read/write, json, csv, os.path, import, sys.argv, pathlib
Mini Projects
calculator, palindrome check, FizzBuzz, word counter, simple to-do CLI, JSON-config reader, dice roller, password generator, tic-tac-toe, file deduper
Mini Projects
calculator, palindrome check, FizzBuzz, word counter, simple to-do CLI, JSON-config reader, dice roller, password generator, tic-tac-toe, file deduper
Comprehensions
list/dict/set comprehensions, nested comprehensions, conditional comprehensions, generator expressions, flattening, matrix transpose, zip in comprehension, enumerate in comprehension, filtering, chain
Comprehensions
list/dict/set comprehensions, nested comprehensions, conditional comprehensions, generator expressions, flattening, matrix transpose, zip in comprehension, enumerate in comprehension, filtering, chain
Iterators & Generators
iter/next protocol, custom __iter__, yield, yield from, infinite generators, generator pipelines, itertools count/cycle/islice, chain, groupby, memory-efficient reads
Decorators & Closures
closures, nonlocal, function decorators, decorators with args, functools.wraps, timing decorator, memoize decorator, retry decorator, class decorator, stacked decorators
Decorators & Closures
closures, nonlocal, function decorators, decorators with args, functools.wraps, timing decorator, memoize decorator, retry decorator, class decorator, stacked decorators
Error Handling
try/except, multiple excepts, else/finally, raising, custom exceptions, exception chaining, assert, EAFP vs LBYL, context of errors, warnings module
Recursion
factorial, fibonacci, sum of digits, reverse string, binary search recursive, tower of hanoi, flatten nested list, tree traversal, permutations, memoized recursion
String Algorithms
anagram check, character frequency, longest word, vowel counter, title-casing, run-length encoding, string compression, substring search, palindrome variants, pangram check
String Algorithms
anagram check, character frequency, longest word, vowel counter, title-casing, run-length encoding, string compression, substring search, palindrome variants, pangram check
List Algorithms
linear search, binary search, bubble sort, selection sort, insertion sort, merge two sorted lists, remove duplicates, rotate list, second largest, chunking
Dictionaries In Depth
defaultdict, Counter, OrderedDict, dict merging, invert dict, nested dict access, grouping records, frequency maps, dict of lists, setdefault patterns
Tuples & Sets In Depth
tuple unpacking, named tuples, swapping, set algebra, dedupe preserving order, frozenset, subset/superset, symmetric difference, membership performance, set of tuples
Tuples & Sets In Depth
tuple unpacking, named tuples, swapping, set algebra, dedupe preserving order, frozenset, subset/superset, symmetric difference, membership performance, set of tuples
Dates & Times
datetime now, formatting strftime, parsing strptime, timedelta math, age calculator, weekday finder, countdown, timezones with zoneinfo, unix timestamps, date ranges
Dates & Times
datetime now, formatting strftime, parsing strptime, timedelta math, age calculator, weekday finder, countdown, timezones with zoneinfo, unix timestamps, date ranges
Math & Numbers
math module, rounding modes, gcd/lcm, prime check, prime sieve, armstrong numbers, perfect numbers, decimal precision, fractions, random sampling
Math & Numbers
math module, rounding modes, gcd/lcm, prime check, prime sieve, armstrong numbers, perfect numbers, decimal precision, fractions, random sampling
Regular Expressions
re.search vs match, findall, groups, named groups, substitution, split, validation email/phone, greedy vs lazy, flags, compile
Functional Python
map, filter, reduce, sorted with key, any/all, functools.partial, operator module, zip/unzip, star unpacking in calls, pipelines
File Handling Advanced
append mode, line-by-line processing, word frequency from file, CSV DictReader/Writer, JSON round-trip, pathlib globbing, temp files, binary files, file stats, merging files
File Handling Advanced
append mode, line-by-line processing, word frequency from file, CSV DictReader/Writer, JSON round-trip, pathlib globbing, temp files, binary files, file stats, merging files
OOP Patterns
encapsulation, classmethod/staticmethod, operator overloading, composition, abstract base classes, mixins, __slots__, property setters, str vs repr, simple singleton
Dataclasses & Typing
dataclass basics, defaults & field(), frozen dataclass, post_init, asdict, typing hints, Optional/Union, TypedDict, Protocol, generics basics
Modules & Packages
import styles, __name__ main guard, sys.argv CLI, argparse basics, argparse subcommands, environment variables, custom module, dir/help introspection, importlib, __all__
Exceptions To Algorithms
stack via list, queue via deque, linked list, binary tree insert/search, BFS, DFS, hash table concept, LRU cache with functools, priority queue heapq, graph adjacency
Sorting & Searching
sorted vs sort, key functions, multi-key sort, reverse sort, bisect module, quicksort, counting sort, sort dict by value, stable sort demo, search in rotated list
Two-D Data & Matrices
nested lists, matrix addition, matrix multiplication, transpose, diagonal sum, spiral traversal, flood fill, grid neighbors, magic square check, game-of-life step
Text Processing
word tokenizer, sentence splitter, stop-word removal, simple markdown to text, template rendering, caesar cipher, vigenere cipher, base64, text stats, find-and-replace CLI
JSON & APIs Offline
json loads/dumps, pretty printing, nested JSON traversal, JSON validation, flatten JSON, config loader, JSON diff, schema-ish checks, JSONL processing, merge JSON files
Comprehension Of Scope
LEGB rule, global keyword, nonlocal, shadowing, default-arg gotcha, late-binding closures, module-level state, constants pattern, name mangling, scope in comprehensions
Concurrency Basics
threading basics, thread join, locks, race-condition demo, ThreadPoolExecutor, multiprocessing Pool, asyncio hello, asyncio gather, async sleep vs time.sleep, producer-consumer queue
Concurrency Basics
threading basics, thread join, locks, race-condition demo, ThreadPoolExecutor, multiprocessing Pool, asyncio hello, asyncio gather, async sleep vs time.sleep, producer-consumer queue
Testing & Debugging
assert-based tests, unittest basics, parametrized checks, doctest, timing with timeit, logging basics, logging levels, pdb-friendly code, tracebacks, defensive programming
Memory & Performance
sys.getsizeof, list vs generator memory, string concatenation costs, slots savings, timeit comparisons, caching with lru_cache, interning demo, shallow vs deep copy, del and gc, profiling with cProfil
Memory & Performance
sys.getsizeof, list vs generator memory, string concatenation costs, slots savings, timeit comparisons, caching with lru_cache, interning demo, shallow vs deep copy, del and gc, profiling with cProfil
Pythonic Idioms
truthiness, chained comparisons, ternary, unpacking swaps, enumerate over range(len), zip iteration, dict.get defaults, context managers, walrus in loops, sentinel values
Data Analysis Lite
csv aggregation, average/median/mode, min-max normalization, moving average, histogram in text, correlation by hand, groupby aggregation, top-N records, pivot-like summary, outlier detection
Practical Scripts
file organizer, bulk renamer, duplicate finder, folder size report, log parser, TODO extractor, backup script, CSV to JSON converter, word occurrence across files, simple scheduler loop
Capstone Challenges
bank account simulator, inventory manager, quiz game, contact book with JSON storage, expense tracker, markdown note manager, hangman, snake-less terminal game, URL shortener logic, mini key-value sto
