🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Design a Ticket Booking System: all 10 questions

Quiz: Design a Ticket Booking System · Question 2 of 10

What does this print? (code)

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))
  1. A.0
  2. B.1
  3. C.2
  4. D.An error
Answer & explanation

Correct answer: 2

Both copies were read before either write, so both "see" a free seat and both book it.

Can you get the rest right without peeking?

Take the timed Quiz: Design a Ticket Booking System quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →