ProgrammingHardTCS CodeVita · Infosys HackWithInfy · Product Company SDE
What does the following Python 3 code print? a, b, c = 11, 3, 27 print((a << b) ^ c, a & ~c, (a | c) >> b)
- A. 67 16 1
- B. 26 0 216
- C. 91 0 3
- D. 67 0 3
Correct answer: D. 67 0 3
Evaluate shifts, then XOR / AND-NOT / OR per the operator precedence given by the parentheses. Output: 67 0 3.
More Python Programming questions
- What does the following Python 3 code print? def f(): try: return 3 finally: print("f", end=" ") x = f() + 17 print(x)
- What does the following Python 3 code print? a, b = [8,5,9,9,3], [5,4,3,3] print(list(map(lambda p: p[0] p[1], zip(a, b)))…
- What does the following Python 3 code print? fs = [lambda: i 5 for i in range(3)] print([f() for f in fs])
- What does the following Python 3 code print? d = {} for w in ["nut","kheer","tea","oat","nut","vada"]: d[w[0]] = d.get(w[0], 0) + 1…
- What does the following Python 3 code print? s = "banana split" print("-".join(s.split("n")[1:]))
- What does the following Python 3 code print? from functools import lrucache calls = 0 @lrucache(None) def f(n): global calls calls += 1…