Python flashcards
Readable code for scripts, web apps, data and AI.
What is Python, in one plain sentence?
Python is a programming language: a way to write instructions a computer follows, using words close to plain English.
Tap to turn over. Swipe right if you know it, left to see it again.
What you will learn
Start from zero
- What Python is4 cards
- Words you need5 cards
- Getting ready and a first program3 cards
Core basics
- How Python runs2 cards
- Values, names and types4 cards
- Strings and formatting3 cards
- Lists, dicts, tuples and sets3 cards
- Loops and blocks2 cards
- Functions and docstrings2 cards
- Input, files and errors3 cards
Next steps
- Comprehensions and built-ins4 cards
- Exceptions, files and data formats4 cards
- Classes and objects3 cards
- Function arguments and defaults2 cards
- Modules, packages and environments5 cards
- Type hints and pattern matching2 cards
- Dates, logging and web APIs3 cards
Go deeper
- Generators and iterators2 cards
- Decorators and context managers2 cards
- Concurrency and the GIL4 cards
- Advanced classes and typing3 cards
- Testing, profiling and memory5 cards
- Gotchas and newer syntax3 cards
Final test and certificate
10 questions drawn fresh from the whole topic, about 15 minutes. Sign in, score 80% or more and get a free certificate with your name and a public check link anyone can open, such as an employer or a teacher. Not signed in? Try a practice test from the cards.
Take the final testAbout these cards
- Reviewed 26 October 2026
- CoversPython 3.14Python 3.15uv 0.13
Checked against
Python at a glance
Python is a programming language for writing instructions a computer follows, in words close to plain English.
Like a recipe: steps in order, ingredients in labelled boxes, and some steps repeated for each item.
Words you will meet
- Interpreter
- The program that reads your code and runs each line
- Variable
- A name label on a value, like age
- Type
- What kind a value is: number, text, true or false
- List
- An ordered row of values you can change
- Dict
- Pairs of keys and values, like a phone book
- Function
- A named set of steps you can reuse
- Loop
- Steps repeated for each item
- Block
- Indented lines that belong together
The steps
- 1. Start from zero (12 cards): What Python is, the words you need, and your first line of code.
- 2. Core basics (19 cards): How Python runs, names and values, types, lists, dicts, loops and functions.
- 3. Next steps (23 cards): Errors, files, classes, packages, environments, typing and the standard library.
- 4. Go deeper (19 cards): Generators, decorators, async, concurrency, the GIL, typing and performance.
All 12 cards in Start from zero
- What is Python, in one plain sentence?
- Python is a programming language: a way to write instructions a computer follows, using words close to plain English.
- What problem does Python solve for everyday people?
- Boring repeated work, like copying 500 marks into a sheet or renaming 300 photos by hand. A short Python script does it in seconds, and it does not get tired or make typing mistakes.
- Where might you already meet Python in daily life?
- Behind many websites and AI chat tools, in banks' reports, in science labs, and in small scripts at offices that tidy files or send daily emails.
- What everyday thing is a Python program most like?
- A recipe. Steps run in order, ingredients sit in labelled boxes, and lines like 'for each egg, crack it' repeat a step many times.
- What do 'code', 'program', 'run' and 'interpreter' mean?
- Code is the text you write; a program is a file of it, like
report.py. To run it, the Python interpreter, the program that reads your code, does each line from top to bottom. - What are a 'value', a 'type' and a 'variable'?
- A value is a piece of data. Its type says what kind:
intwhole number,floatdecimal,strtext in quotes,boolTrueorFalse. A variable is a name label on a value:age = 12. - What are a 'list', a 'dict', a 'tuple' and a 'set'?
- Ways to hold many values. A list is an ordered row,
["tea", "rice"]. A dict pairs keys with values,{"rice": 40}. A tuple is a fixed list,(13.08, 80.27). A set keeps no duplicates,{101, 102}. - What do 'function', 'return' and 'method' mean?
- A function is a named set of steps you can reuse, like
print. It may return, that is hand back, a result. A method is a function that belongs to a value, likename.upper(). - What are a 'loop', a 'block' and an 'error'?
- A loop like
forrepeats steps for each item. The indented lines under it form a block, and Python uses that indent to know what is inside. An error, also called an exception, is Python stopping to say something went wrong. - What do you need before starting this topic?
- A computer with Python 3 from python.org, a terminal (a text window for typing commands) and a text editor. Later you will use pip, the tool that installs packages: ready-made code others shared.
- Your first tiny win: what does this print?
- The first line stores the text in a variable called name.
printshows the joined text on screen, so you see a greeting with that name. - What will you be able to do after this topic?
- Write small scripts that work with text, numbers and lists, read files, handle bad input without crashing, and split work into clean functions.
Python cheatsheet
Strings and formatting
s.strip() / s.removeprefix("v")Trim spaces / drop a known prefixs.split(",", maxsplit=1)Split, at most once", ".join(names)Join items into one stringf"{amount:,.2f}"1,234.50 style numberf"{ratio:.1%}"Percentage, one decimalf"{user_id=}"Debug print:user_id=812f"{name!r:>12}"repr, right aligned in 12s.casefold() == t.casefold()Case-insensitive compare
Collections
d.get(k, default)Read withoutKeyErrord.setdefault(k, []).append(x)Group without checksa | b / d |= otherMerge dicts (3.9+)Counter(xs).most_common(3)Top 3 by countdefaultdict(list)Auto empty list per keydeque(maxlen=100)Fast queue, keeps last 100dict.fromkeys(emails)Dedupe, keep ordersorted(xs, key=itemgetter(1), reverse=True)Sort by field, descendingbisect.insort(xs, x)Insert keeping a list sorted
Iteration
enumerate(xs, start=1)Index plus itemzip(a, b, strict=True)Pairs; error on length mismatchitertools.batched(xs, 100)Chunks of 100 (3.12+)itertools.chain.from_iterable(lists)Flatten one levelitertools.groupby(sorted_xs, key)Group runs; sort firstitertools.pairwise(xs)Neighbours: (a,b), (b,c)any(...) / all(...)Short-circuit checksnext(iter(xs), None)First item orNone
Tooling
uv init / uv add httpxNew project / add dependencyuv run pytest -qRun in the synced environmentuv python install 3.14Install a Python versionuvx ruff check --fix .Lint and auto-fixruff format .Format codepyright / mypy --strictStatic type checkpytest -x -k invoice --lfStop on fail, filter, rerun failurespython3 -X importtime app.pyFind slow imports
Debug and profile
breakpoint()Drop intopdbherepython3 -m pdb -c continue app.pyDebugger on crashpython3 -m cProfile -s cumtime app.pyWhere time goespy-spy top --pid PIDProfile a live processpython3 -m json.tool data.jsonPretty-print JSONtracemalloc.start()Track memory allocationspython3 -W error app.pyTurn warnings into errors