Skills101
← All practice quizzes

Quiz: Design a Ticket Booking System

5 questions · new set on every retakeNo time limitPass: 60%+10 XP on first pass

The one rule: the same seat must never be sold twice, even when a million people click at once. See a double booking happen, prevent it with a conditional update in SQLite, hold seats with a timeout, and survive the rush with a waiting room.

Log in to take the quiz

Free account · see your score, answers and explanations, earn XP

  1. Question 1

    What causes double booking in "check, then act" code?

  2. Question 2

    What does this print?

    seat = "FREE"
    a = seat
    b = seat
    sold = []
    if a == "FREE":
        seat = "BOOKED"; sold.append("A")
    if b == "FREE":
        seat = "BOOKED"; sold.append("B")
    print(len(sold))
    
  3. Question 3

    After running UPDATE seats SET status='HELD' ... WHERE id='B7' AND status='FREE', how does the app know whether it got the seat?

  4. Question 4

    Why should seat holds have an expiry time?

  5. Question 5

    What does this print?

    import sqlite3
    db = sqlite3.connect(":memory:")
    db.execute("CREATE TABLE s (id TEXT, status TEXT)")
    db.execute("INSERT INTO s VALUES ('A1', 'FREE')")
    r1 = db.execute("UPDATE s SET status='HELD' WHERE id='A1' AND status='FREE'").rowcount
    r2 = db.execute("UPDATE s SET status='HELD' WHERE id='A1' AND status='FREE'").rowcount
    print(r1, r2)
    
🎯 Today’s placement challenge — 10 questions, no login. Can you score 10/10?Take today’s challenge →