ProgrammingVery hardTCS NQT · Accenture
What is printed?
What is printed?
print(f'{"":>3}|', f'{"x":^3}|', f'{None!s:>6}|')- A. | z | None|
- B. | x | None|
- C. | x | Nona|
- D. | y | None|
Correct answer: B. | x | None|
An empty string right-aligned to three columns is three spaces. The centre spec gives x one space on each side, and !s with width six pads None on the left.
More Python Programming questions
- 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)…
- A program sorts the whole list again for each of 10^5 queries on a list of 10^5 items. Which statement about running it in CPython is…