ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

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

Correct answer: D. 0 3

bisect_left returns the first index of the run of 1s, which is 0. bisect_right returns the index after the last 1, which is 3.

More Python Programming questions

Exams that ask this topic