🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Queues and Microservices: all 10 questions

Quiz: Queues and Microservices · Question 8 of 10

What does this print? (code)

What does this print?

processed = set()
wallet = 0
for msg_id, amount in [("m1", 500), ("m2", 200), ("m1", 500)]:
    if msg_id in processed:
        continue
    processed.add(msg_id)
    wallet += amount
print(wallet)
  1. A.1200
  2. B.700
  3. C.500
  4. D.200
Answer & explanation

Correct answer: 700

The repeated m1 message is skipped, so only 500 + 200 is added.

Can you get the rest right without peeking?

Take the timed Quiz: Queues and Microservices quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →