ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(sum(divmod(17, 5)), divmod(-17, 5)[1], 17 % 5 - (-17) % 5)
- A. 6 3 -5
- B. 5 3 -1
- C. 5 2 5
- D. 5 3 5
Correct answer: B. 5 3 -1
divmod(17, 5) is (3, 2), and their sum is 5. -17 % 5 is 3. The last term is 17 % 5 - (-17) % 5 = 2 - 3 = -1.
More Python Programming questions
- What is printed? python def prodexcept(a): n = len(a) out = [1] n left = 1 for i in range(n): out[i] = left left = a[i] right = 1 for i in…
- What is printed? python import bisect def span(a, x): lo = bisect.bisectleft(a, x) if lo == len(a) or a[lo] != x: return (-1, -1) return…
- What is printed? python def palsub(s): n = len(s) best = '' for c in range(2 n - 1): l, r = c // 2, c // 2 + c % 2 while l >= 0 and r < n…
- What is printed? python def partition(s): last = {ch: i for i, ch in enumerate(s)} out = [] start = end = 0 for i, ch in enumerate(s): end…
- What is printed? python def units(boxes, cap): boxes = sorted(boxes, key=lambda b: -b[1]) total = 0 for n, u in boxes: take = min(n, cap)…
- What is printed? python def minremove(iv): iv = sorted(iv, key=lambda x: x[1]) keep = 0 end = float('-inf') for s, e in iv: if s >= end…