ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
import bisect
print(bisect.bisect_right([1, 2, 2, 3], 2, lo=2))
  1. A. 2
  2. B. 4
  3. C. 1
  4. D. 3

Correct answer: D. 3

This search only looks at indices 2 and 3, which hold 2 and 3. bisect_right puts the value after the last 2, which is index 3.

More Python Programming questions

Exams that ask this topic