ProgrammingModerateTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
import bisect print(bisect.bisect([1, 2, 2, 5], 2))
- A. 2
- B. 1
- C. 4
- D. 3
Correct answer: D. 3
bisect (same as bisect_right) returns the insertion point after all entries equal to 2, which is index 3. Use bisect_left to get index 1 instead.
More Python Programming questions
- What is printed? python try: sorted([3, 'a']) except TypeError as e: print(e)
- A Python solution reads n = 10^6 numbers with input() in a loop, calling int(input()) for each line. Which change is the most effective…
- What is printed? python import math print(math.gcd(12, 18, 27), math.lcm(4, 6), math.gcd())
- What is printed? python print(divmod(-(10 20), 7))
- What is printed? python import heapq h = [4, 1, 3] heapq.heapify(h) print(h[0], sorted(h))
- What is printed? python from collections import deque d = deque([1, 2, 3, 4, 5], maxlen=3) d.append(6) d.appendleft(0) print(list(d))