· 3 min read

Memorize Python Data Structures and Comprehensions: 125 Flashcards on Lists, Dicts, Sets and Generators

Learn Python lists, tuples, sets, dicts, comprehensions and generators with 125 real flashcards from deck JL4402 on Flip It, plus a 3-round study plan and Python-specific tips.

Glowing Python snake coiled around bracket-shaped containers and a nested grid of cubes, surrounded by floating flashcards

Studying. But it's also a video game. 🎮

Flashcards, quizzes and games that make you actually remember.

Start playing — it's free

Posted by

Confident Python developers know, without looking it up, when a tuple beats a list, why {} is not an empty set, and how a generator expression differs from a list comprehension. Deck JL4402 — Python: Data Structures & Comprehensions on Flip It packs exactly that into 125 flashcards based on the official Python tutorial. Here is how to memorize them.

Study this deck: Python: Data Structures & Comprehensions

1 / 10
Question

List.append(x)

Knew itLearning

Tap the card for the answer · swipe right if you knew it, left if not

What the 125 cards cover

The deck moves through five blocks, in roughly this order:

  • List methods — append, extend, insert, remove, pop, clear, index, count, sort, reverse, copy, plus lists as stacks and why collections.deque beats a list as a queue.
  • Tuples and sets — immutability, the one-item tuple ('hello',), packing/unpacking, set() vs {}, set difference a - b, set comprehensions.
  • Dictionaries — immutable keys only, d[key] vs d.get(key), KeyError, dict.items(), insertion order since 3.7, dict(zip(keys, values)), duplicate keys in comprehensions (last value wins).
  • Looping and comparison — enumerate, zip, reversed, sorted, sorted(set(seq)), in / not in, is vs ==, chained comparisons, short-circuit and/or, the walrus operator :=, lexicographical sequence ordering.
  • Comprehensions and generators — nested comprehensions, matrix transposition, flattening, yield, next(), StopIteration, send(), close(), throw(), yield from, recursive generators, lazy evaluation, any()/all()/sum()/max() over generators.

Sample flashcards from the deck

FrontBack
Create a tuple with one itemFollow the value with a comma: ('hello',) — parentheses alone are not sufficient
Create an empty setUse set() — not {}, which creates an empty dictionary
del a[i] vs a.pop(i)del removes the item; pop removes and returns it
sorted() vs list.sort()sorted() returns a new sorted list; list.sort() sorts in place and returns None
Preferred way to transpose a matrixlist(zip(*matrix)) — built-in functions over complex comprehensions
Syntax for flattening a nested list[num for elem in nested_list for num in elem]
What exception does a generator raise when exhausted?StopIteration, raised by __next__() when there are no more elements
Can you reset a generator to the beginning?No. Generators only go forward; call the generator function again to restart
() vs [] for comprehensions() creates a lazy generator, [] creates a list with all values in memory
Can you use the walrus operator in comprehensions?Yes (Python 3.8+): [y for x in data if (y := f(x)) > 0]

A three-round plan for 125 cards

Round 1 — the mutability map (lists, tuples, sets, dicts). Tag every card mutable or immutable. That one distinction explains why tuples can be dict keys and lists cannot, why list.sort() returns None, and why del a[:] equals a.clear().

Round 2 — the loop idioms. Drill the enumerate, zip, reversed, sorted and items() cards until for k, v in d.items(): comes out automatically — these are the cards interviewers test.

Round 3 — comprehensions and generators. Keep a REPL open. When a card gives [x**2 for x in range(10)], type it, then the generator version (x**2 for x in range(10)) and call next() on it. Seeing <generator object> once is worth ten reviews.

Two Python-specific tips

  1. Read the brackets first. For every comprehension card, before reading the expression, name the delimiter: [] list, {} set or dict (dict if there is a colon), () generator. The deck deliberately contrasts [x, y for x in range(3)] (SyntaxError) with [(x, y) for x in range(3)] — that one card catches a bug you will otherwise ship.
  2. Group the "returns None" cards. append, insert, remove, sort, reverse, clear, extend all return None because they mutate in place. Learn them as one family and x = my_list.sort() will never bite you again.

Start reviewing

Log in to Flip It and search the library for deck code JL4402 (Python: Data Structures & Comprehensions). Spaced repetition schedules the 125 cards for you; about two weeks of ten-minute sessions gets them to stable recall.

Working through the other backend languages? Try the Java core concepts and OOP study guide or the Go essentials guide.

Ready to learn faster? 🚀

Join FLIP IT for free and turn studying into a game.

Create my free account