Turning Learners Into Developers
Codekilla
CODEKILLA
// examples.python()

Python examples.

Simple, readable, powerful.

Python543 programs runnable inline55 chapters
Chapter 01 of 55·10 programs

Python Basics

print, variables, comments, escape sequences, type(), input/output

Chapter 02 of 55·3 programs

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.

Chapter 03 of 55·10 programs

Operators & Math

arithmetic, comparison, logical, bitwise, walrus, augmented assignment

Chapter 04 of 55·10 programs

Operators & Math

arithmetic, comparison, logical, bitwise, walrus, augmented assignment

Chapter 05 of 55·10 programs

Strings

indexing, slicing, f-strings, .format(), methods (upper/lower/split/join/replace/strip), repr

Chapter 06 of 55·10 programs

Strings

indexing, slicing, f-strings, .format(), methods (upper/lower/split/join/replace/strip), repr

Chapter 07 of 55·10 programs

Lists & Tuples

create, index, slice, append/extend/insert, sort/reverse, comprehensions, unpacking

Chapter 08 of 55·10 programs

Dicts & Sets

key access, .get/.setdefault, iteration, dict comprehension, set ops (union/intersection/diff)

Chapter 09 of 55·10 programs

Dicts & Sets

key access, .get/.setdefault, iteration, dict comprehension, set ops (union/intersection/diff)

Chapter 10 of 55·10 programs

Control Flow

if/elif/else, for, while, range, break/continue, else-on-loop, match (3.10+)

Chapter 11 of 55·10 programs

Functions

def, default args, *args/**kwargs, lambda, decorators (basic), recursion, type hints

Chapter 12 of 55·10 programs

Classes & OOP

class, __init__, self, dunder methods, inheritance, super, @property, dataclasses

Chapter 13 of 55·10 programs

Classes & OOP

class, __init__, self, dunder methods, inheritance, super, @property, dataclasses

Chapter 14 of 55·10 programs

File I/O & Modules

open with-block, read/write, json, csv, os.path, import, sys.argv, pathlib

Chapter 15 of 55·10 programs

Mini Projects

calculator, palindrome check, FizzBuzz, word counter, simple to-do CLI, JSON-config reader, dice roller, password generator, tic-tac-toe, file deduper

Chapter 16 of 55·10 programs

Mini Projects

calculator, palindrome check, FizzBuzz, word counter, simple to-do CLI, JSON-config reader, dice roller, password generator, tic-tac-toe, file deduper

Chapter 17 of 55·10 programs

Comprehensions

list/dict/set comprehensions, nested comprehensions, conditional comprehensions, generator expressions, flattening, matrix transpose, zip in comprehension, enumerate in comprehension, filtering, chain

Chapter 18 of 55·10 programs

Comprehensions

list/dict/set comprehensions, nested comprehensions, conditional comprehensions, generator expressions, flattening, matrix transpose, zip in comprehension, enumerate in comprehension, filtering, chain

Chapter 19 of 55·10 programs

Iterators & Generators

iter/next protocol, custom __iter__, yield, yield from, infinite generators, generator pipelines, itertools count/cycle/islice, chain, groupby, memory-efficient reads

Chapter 20 of 55·10 programs

Decorators & Closures

closures, nonlocal, function decorators, decorators with args, functools.wraps, timing decorator, memoize decorator, retry decorator, class decorator, stacked decorators

Chapter 21 of 55·10 programs

Decorators & Closures

closures, nonlocal, function decorators, decorators with args, functools.wraps, timing decorator, memoize decorator, retry decorator, class decorator, stacked decorators

Chapter 22 of 55·10 programs

Error Handling

try/except, multiple excepts, else/finally, raising, custom exceptions, exception chaining, assert, EAFP vs LBYL, context of errors, warnings module

Chapter 23 of 55·10 programs

Recursion

factorial, fibonacci, sum of digits, reverse string, binary search recursive, tower of hanoi, flatten nested list, tree traversal, permutations, memoized recursion

Chapter 24 of 55·10 programs

String Algorithms

anagram check, character frequency, longest word, vowel counter, title-casing, run-length encoding, string compression, substring search, palindrome variants, pangram check

Chapter 25 of 55·10 programs

String Algorithms

anagram check, character frequency, longest word, vowel counter, title-casing, run-length encoding, string compression, substring search, palindrome variants, pangram check

Chapter 26 of 55·10 programs

List Algorithms

linear search, binary search, bubble sort, selection sort, insertion sort, merge two sorted lists, remove duplicates, rotate list, second largest, chunking

Chapter 27 of 55·10 programs

Dictionaries In Depth

defaultdict, Counter, OrderedDict, dict merging, invert dict, nested dict access, grouping records, frequency maps, dict of lists, setdefault patterns

Chapter 28 of 55·10 programs

Tuples & Sets In Depth

tuple unpacking, named tuples, swapping, set algebra, dedupe preserving order, frozenset, subset/superset, symmetric difference, membership performance, set of tuples

Chapter 29 of 55·10 programs

Tuples & Sets In Depth

tuple unpacking, named tuples, swapping, set algebra, dedupe preserving order, frozenset, subset/superset, symmetric difference, membership performance, set of tuples

Chapter 30 of 55·10 programs

Dates & Times

datetime now, formatting strftime, parsing strptime, timedelta math, age calculator, weekday finder, countdown, timezones with zoneinfo, unix timestamps, date ranges

Chapter 31 of 55·10 programs

Dates & Times

datetime now, formatting strftime, parsing strptime, timedelta math, age calculator, weekday finder, countdown, timezones with zoneinfo, unix timestamps, date ranges

Chapter 32 of 55·10 programs

Math & Numbers

math module, rounding modes, gcd/lcm, prime check, prime sieve, armstrong numbers, perfect numbers, decimal precision, fractions, random sampling

Chapter 33 of 55·10 programs

Math & Numbers

math module, rounding modes, gcd/lcm, prime check, prime sieve, armstrong numbers, perfect numbers, decimal precision, fractions, random sampling

Chapter 34 of 55·10 programs

Regular Expressions

re.search vs match, findall, groups, named groups, substitution, split, validation email/phone, greedy vs lazy, flags, compile

Chapter 35 of 55·10 programs

Functional Python

map, filter, reduce, sorted with key, any/all, functools.partial, operator module, zip/unzip, star unpacking in calls, pipelines

Chapter 36 of 55·10 programs

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

Chapter 37 of 55·10 programs

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

Chapter 38 of 55·10 programs

OOP Patterns

encapsulation, classmethod/staticmethod, operator overloading, composition, abstract base classes, mixins, __slots__, property setters, str vs repr, simple singleton

Chapter 39 of 55·10 programs

Dataclasses & Typing

dataclass basics, defaults & field(), frozen dataclass, post_init, asdict, typing hints, Optional/Union, TypedDict, Protocol, generics basics

Chapter 40 of 55·10 programs

Modules & Packages

import styles, __name__ main guard, sys.argv CLI, argparse basics, argparse subcommands, environment variables, custom module, dir/help introspection, importlib, __all__

Chapter 41 of 55·10 programs

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

Chapter 42 of 55·10 programs

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

Chapter 43 of 55·10 programs

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

Chapter 44 of 55·10 programs

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

Chapter 45 of 55·10 programs

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

Chapter 46 of 55·10 programs

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

Chapter 47 of 55·10 programs

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

Chapter 48 of 55·10 programs

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

Chapter 49 of 55·10 programs

Testing & Debugging

assert-based tests, unittest basics, parametrized checks, doctest, timing with timeit, logging basics, logging levels, pdb-friendly code, tracebacks, defensive programming

Chapter 50 of 55·10 programs

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

Chapter 51 of 55·10 programs

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

Chapter 52 of 55·10 programs

Pythonic Idioms

truthiness, chained comparisons, ternary, unpacking swaps, enumerate over range(len), zip iteration, dict.get defaults, context managers, walrus in loops, sentinel values

Chapter 53 of 55·10 programs

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

Chapter 54 of 55·10 programs

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

Chapter 55 of 55·10 programs

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