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

Quiz: Databases at Scale · Question 8 of 10

What does this print? (code)

What does this print?

users = [101, 102, 103, 104, 105, 106]
shards = {0: [], 1: [], 2: []}
for u in users:
    shards[u % 3].append(u)
print(shards[0], shards[2])
  1. A.[101, 104] [103, 106]
  2. B.[103, 106] [101, 104]
  3. C.[102, 105] [101, 104]
  4. D.[102, 105] [103, 106]
Answer & explanation

Correct answer: [102, 105] [101, 104]

102 and 105 leave remainder 0; 101 and 104 leave remainder 2.

Can you get the rest right without peeking?

Take the timed Quiz: Databases at Scale quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →