🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Consistent Hashing: all 15 questions

Quiz: Consistent Hashing · Question 7 of 15

What does this print? (code)

What does this print?

keys = range(12)
moved = sum(1 for k in keys if k % 3 != k % 4)
print(moved)
  1. A.3
  2. B.9
  3. C.6
  4. D.12
Answer & explanation

Correct answer: 9

Only 0, 1 and 2 give the same answer for % 3 and % 4, so 9 of 12 keys move — the modulo problem in miniature.

Can you get the rest right without peeking?

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

Start the quiz →