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

Quiz: Scaling and Load Balancing · Question 7 of 10

What does this print? (code)

What does this print?

servers = ["S1", "S2", "S3"]
picked = [servers[i % len(servers)] for i in range(5)]
print(picked)
  1. A.['S1', 'S2', 'S3', 'S3', 'S3']
  2. B.['S1', 'S2', 'S3', 'S1', 'S2']
  3. C.['S1', 'S1', 'S2', 'S2', 'S3']
  4. D.['S2', 'S3', 'S1', 'S2', 'S3']
Answer & explanation

Correct answer: ['S1', 'S2', 'S3', 'S1', 'S2']

Round robin cycles through the servers in order: 1, 2, 3, 1, 2.

Can you get the rest right without peeking?

Take the timed Quiz: Scaling and Load Balancing quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →