ProgrammingModerateTCS NQT · Wipro pattern
What is printed?
What is printed?
print(3 % 2 == 1 and 4 % 2 == 0, 3 // 2 == 1 or 1 / 0)
- A. True True
- B. True False
- C. False True
- D. ZeroDivisionError
Correct answer: A. True True
Both halves of the and are True, and the or short-circuits because 3 // 2 is 1, so 1 / 0 is never evaluated.
More Python Programming questions
- What is printed? python print(f'{"":>3}|', f'{"x":^3}|', f'{None!s:>6}|')
- What is printed? python from functools import lrucache @lrucache(maxsize=None) def t(n): if n == 0: return 0 if n < 3: return 1 return t(n…
- What is printed? python from collections import deque def countpaths(g): R, C = len(g), len(g[0]) dist = [[-1] C for in range(R)] ways =…
- What is printed? python def cnt(a, k): pre = {0: 1} s = ans = 0 for x in a: s += x ans += pre.get(s - k, 0) pre[s] = pre.get(s, 0) + 1…
- What is printed? python def twotx(p): b1 = b2 = float('-inf') s1 = s2 = 0 for x in p: b1 = max(b1, -x) s1 = max(s1, b1 + x) b2 = max(b2…
- What is printed? python def tile(n): dp = [0] (n + 1) dp[0] = 1 for i in range(1, n + 1): dp[i] = dp[i - 1] + (dp[i - 2] if i >= 2 else 0)…