Part 14 / Topic 3 of 6
Demo data
Never demo on real customer data — one confidential name on a projector is a security incident (Part 12), and real data tells a ragged story. Seeded demo data is believable, safe, and tells the same story every time:
# examples/01_seeded_demo_data_the_same_believable.py
import random
def demo_shipments(n, seed=2025):
rng = random.Random(seed)
cities = ["Mumbai", "Pune", "Delhi", "Jaipur", "Chennai", "Bengaluru"]
rows = []
for i in range(n):
origin, dest = rng.sample(cities, 2)
rows.append({"id": f"S-{3000 + i}", "route": f"{origin} -> {dest}",
"status": rng.choices(["delivered", "in_transit", "delayed"], weights=[6, 3, 1])[0]})
return rows
first, second = demo_shipments(4), demo_shipments(4)
for r in first:
print(r)
print("identical on every run:", first == second)
# {'id': 'S-3000', 'route': 'Chennai -> Mumbai', 'status': 'in_transit'}
# {'id': 'S-3001', 'route': 'Jaipur -> Pune', 'status': 'delivered'}
# {'id': 'S-3002', 'route': 'Delhi -> Jaipur', 'status': 'delivered'}
# {'id': 'S-3003', 'route': 'Mumbai -> Jaipur', 'status': 'delivered'}
# identical on every run: True
Craft the dataset like a screenwriter: realistic routes the audience recognises, a mostly-healthy distribution (weights 6/3/1), and the one delayed shipment you will click on, in the same place every run. If the rehearsal showed S-3000 in transit, the demo will too.
🧪 Quick quiz
- Why use seeded, scripted demo data?
Show the answer
The demo tells the same story every time and never shows confidential customer data by accident. Two runs of the generator produced identical rows. (verified against the example output above)
Done here? The practice set for Part 14 — 4 exercises with solutions — is on the part page.