ProgrammingModerateTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
import math print(math.isqrt(99), math.isqrt(100), round(2.5), round(3.5))
- A. 10 10 2 4
- B. 9 10 2 3
- C. 9 10 2 4
- D. 9 10 3 4
Correct answer: C. 9 10 2 4
isqrt returns the floor of the exact square root, so 99 gives 9 and 100 gives 10. round uses banker's rounding: ties go to the even neighbour, so 2.5 becomes 2 and 3.5 becomes 4.
More Python Programming questions
- What is printed? python import itertools print(list(itertools.accumulate([3, 1, 4, 1, 5], max))[-1], list(itertools.accumulate([3, 1, 4]…
- What is printed? python import heapq print(heapq.heappop([]) if False else 'ok', heapq.nlargest(1, []))
- What is the time complexity of building a heap from n items with heapq.heapify, compared with pushing the n items one by one with…
- What is printed? python x = 255 print(x.bitlength(), bin(x).count('1'), (x & -x), (x - 1) & x)
- What is printed? python print(-7 // 2, 7 // -2, -7 % 2, 7 % -2)
- What is printed? python def pairs(a, t): a = sorted(a) i, j, c = 0, len(a) - 1, 0 while i < j: s = a[i] + a[j] if s == t: c += 1 i += 1 j…