ProgrammingHardGATE CS & IT · Infosys
What is printed?
What is printed?
print(-1 >> 1, -8 >> 2, 1 << 70 > 10**20, (-5) & 0xF)
- A. 0 -2 True 11
- B. -1 -2 True 11
- C. -1 -2 False 11
- D. -1 -2 True 5
Correct answer: B. -1 -2 True 11
Right shift on a negative number is arithmetic, so -1 stays -1 and -8 >> 2 is -2. 1 << 70 is far larger than 10^20, and (-5) & 0xF is 11 in two's complement.
More Python Programming questions
- What is printed? python print(0 or [] or 'x', 2 and 0 and 5, None or 0)
- What is printed? python d = {} d.setdefault('k', []).append(1) d.setdefault('k', []).append(2) print(d, d.setdefault('j', 9), 'j' in d)
- What is printed? python w = ['pear', 'fig', 'apple', 'kiwi', 'date'] print(sorted(w, key=lambda s: (len(s), s)), sorted(w, key=len…
- What is printed? python print(bool(0.0), bool(' '), bool(None is None), bool(float('nan')))
- What is printed? python def findmin(a): lo, hi = 0, len(a) - 1 while lo < hi: mid = (lo + hi) // 2 if a[mid] > a[hi]: lo = mid + 1 else…
- What is printed? python g = {'a': [3, 1], 'b': [2]} for v in g.values(): v.sort() print(g, sorted(g.items(), key=lambda kv: len(kv[1])…