ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(1 << 64 == 2**64, (1 << 64) - 1 & 0xFFFF)
- A. False 65535
- B. True 65536
- C. True 0
- D. True 65535
Correct answer: D. True 65535
<< binds tighter than ==, so the first test is True. Subtraction binds tighter than &, so the second value is ((1 << 64) - 1) & 0xFFFF = 65535.
More Python Programming questions
- What is printed? python print(0.1 + 0.2 == 0.3, round(0.1 + 0.2, 10) == 0.3, 0.1 + 0.2)
- What is printed? python print(round(2.5), round(3.5), round(-0.5), round(2.675, 2), round(1.005, 2))
- What is printed? python a = float('nan') b = float('nan') print(a == a, a is a, a == b, [a] == [a], [b] == [a])
- What is printed? python print(253 + 1 == 253 + 1.0, 253 + 1 == 253, float(253 + 1) == 253)
- What is printed? python pairs = [(2, 'b'), (1, 'z'), (2, 'a'), (1, 'y')] print(sorted(pairs, key=lambda t: t[0])) print(sorted(pairs…
- What is printed on the second line? python words = ['pear', 'fig', 'apple', 'kiwi', 'date'] print(sorted(words, key=lambda w: (-len(w)…