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))
- A. 3 0
- B. 1 3
- C. 0 1
- 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
- What is printed? python print(0.1 0.1 == 0.01, round(0.1 0.1, 2) == 0.01)
- What is printed? python print(list(filter(None, [0, 1, '', 'a', None, [], [0]])))
- What is printed? python x = 5 print(x.add(3), (5).bitlength(), 5 .real)
- What is printed? python print({{'a': 1, 'b': 2}, 'a': 3})
- What is printed? python a, b, c = [1, 2, 3, 4] print(a, b, c)
- What is printed? python print(12 & -12, 12 & 11, ~12 & 0xF)