20-Minute Diagnostic
Answer without running code. Give yourself one point per correct answer and one point per clear explanation.
Questions
- What is printed, and why?
python
rows = [[0]] * 3
rows[0].append(1)
print(rows)
- Why is
def add(x, items=[]): ...usually a bug? Give a correct alternative. - When can
a == bbe true whilea is bis false? - Why can
(1, [2])not be a dictionary key even though it is a tuple? - What does a generator save compared with a list, and what does it cost?
- What is the difference between an iterable and an iterator?
- Does a type annotation reject the wrong type at runtime?
- When would a
Protocolbe preferable to an abstract base class? - What work is suitable for threads, processes, and
asynciorespectively? - Does the GIL make race conditions impossible?
- Name three measurements needed before calling code “fast.”
- Why is average latency insufficient for a trading system?
- What should happen when a market-data consumer cannot keep up?
- Name four forms of look-ahead or survivorship bias.
- What makes a backtest replay deterministic?
- Distinguish event time, ingestion time, and processing time.
- How would you make order submission retry-safe?
- What would you log/measure around a live strategy?
- Sketch a safe schema migration for a shared event.
- State one production incident as: symptom, impact, evidence, action, prevention.
Scoring
- 32–40: compress the early chapters; spend time on design and mocks.
- 22–31: follow the three-day plan as written.
- 12–21: prioritize Chapters 1–8 and one backtesting chapter.
- 0–11: three days is a crash course; focus on correctness and honest reasoning.
Answer checkpoints
- All three rows reference the same inner list:
[[0, 1], [0, 1], [0, 1]]. - The default is created once. Use
None, then allocate inside. - Equality compares value by a type-defined rule; identity compares object identity.
- Hashability is recursive: the nested list is mutable and unhashable.
- Lazy iteration saves peak memory and can reduce latency-to-first-result; it is single-pass unless recreated and may defer exceptions.
- An iterable can produce an iterator; an iterator also carries traversal state.
- No. Annotations are metadata used by tools unless code explicitly enforces them.
- When consumers need structural typing without inheritance or runtime coupling.
- Usually: threads for blocking I/O or C extensions releasing the GIL; processes for isolated CPU-bound Python; asyncio for many cooperatively scheduled I/O tasks.
- No. Operations can interleave, extension code may release it, and compound invariants still require synchronization.
- Workload, baseline, and distribution (including p95/p99), plus CPU/memory/allocations.
- A small set of slow events can dominate risk while barely moving the mean.
- Apply a declared policy: block/backpressure, coalesce, shed, spill, or fail closed.
- Future prices, revised fundamentals, today’s universe, delisted-name exclusion, future-aware normalization, or impossible fills.
- Stable inputs, total event ordering, explicit seeds, deterministic clocks, and recorded configuration/code version.
- When the source says it happened; when the platform received it; when this stage handled it.
- Stable client order ID plus deduplication and query/reconcile after ambiguity.
- Inputs, decisions, orders, acknowledgements/fills, positions, risk, errors, queue depth, freshness, latency percentiles, version, and correlation IDs.
- Additive compatible change, dual read/write if needed, backfill, measure, switch, then remove only after all consumers migrate.
- A strong answer separates facts from guesses and ends with a system improvement.