ProgrammingHardTCS CodeVita · Infosys HackWithInfy · Product Company SDE
What does the following Python 3 code print? a, b, c = 25, 3, 17 print((a << b) ^ c, a & ~c, (a | c) >> b)
- A. 217 0 2
- B. 18 8 200
- C. 217 17 3
- D. 217 8 3
Correct answer: D. 217 8 3
Evaluate shifts, then XOR / AND-NOT / OR per the operator precedence given by the parentheses. Output: 217 8 3.
More Python Programming questions
- What does the following Python 3 code print? def f(): try: return 7 finally: print("f", end=" ") x = f() + 13 print(x)
- What does the following Python 3 code print? a, b = [3,1,8,5,4,7], [7,4,2,5] print(list(map(lambda p: p[0] p[1], zip(a, b)))…
- What does the following Python 3 code print? d = {} for w in ["kheer","ghee","bun","nut","cake","jam"]: d[w[0]] = d.get(w[0], 0) + 1…
- What does the following Python 3 code print? a, b = 18, 5 print(a // b, a % b, -a // b, -a % b)
- What does the following Python 3 code print? a = [[0] 2] 2 a[0][0] = 7 print(a)
- What does the following Python 3 code print? print(sum(x x for x in range(30) if x % 4 == 1))