← 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))
- A.0
- B.1
- C.2
- 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 →