ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(0xFF >> 4 << 4 == 0xF0, 1 << 63 > 0, (1 << 63) - 1 == 2**63 - 1, -(1 << 63) >> 63)
- A. True True True 0
- B. False True True -1
- C. True False True -1
- D. True True True -1
Correct answer: D. True True True -1
Right shift on a negative int floors, so -(2**63) >> 63 is -1 rather than 0. Shifts on Python ints do not wrap at 64 bits.
More Python Programming questions
- What is printed on the third line? python names = ['bob', 'Alice', 'carl', 'Bob', 'alice'] print(sorted(names)) print(sorted(names…
- What is printed? python x = 253 print(float(x + 1) == x, x + 1.0 == x, (x + 2.0) - x, int(float(x + 3)) - x)
- What is printed? python print([10, 20, 30][True], (5).bitlength(), (True).bitlength(), (-1).bitlength())
- What is printed? python print(round(7.5), round(6.5), round(-7.5), round(7.5000001))
- What is printed? python print(-7.5 % 2, 7.5 % -2, -0.0 % 3)
- What is printed? python words = 'the quick brown the lazy the'.split() counts = {} for w in words: counts[w] = counts.get(w, 0) + 1…