🎙 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 13 of 15

What does this print? (code)

What does this print?

import bisect
points = [(40, "A"), (130, "B"), (220, "C")]
def owner(pos):
    i = bisect.bisect(points, (pos,))
    return points[i % len(points)][1]
print(owner(10), owner(131), owner(250))
  1. A.A C C
  2. B.B C A
  3. C.A B C
  4. D.A C A
Answer & explanation

Correct answer: A C A

10 goes to A at 40; 131 is just past B so it goes to C; 250 is past C and wraps to A.

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 →