ProgrammingHardTCS NQT · Accenture
What is printed?
What is printed?
print(0b1010 & ~0b10, 0b1010 ^ 0b1111, 1 << 3 | 1, 6 & 3 == 2)
- A. 8 5 9 True
- B. 8 5 9 False
- C. 8 5 0 True
- D. 8 5 9 1
Correct answer: A. 8 5 9 True
~0b10 clears bit 1, so 1010 & ...11101 is 1000 = 8. The comparison 6 & 3 == 2 is True because & binds tighter than == in Python, and 6 & 3 is 2.
More Python Programming questions
- What is printed? python print(1 << 100 >> 99) try: print(1 >> -1) except ValueError as e: print(e)
- What is printed? python print(len(str(21000)), sum(map(int, str(21000))))
- What is printed? python print(1018 10 // 1018 == 10, type(1018 / 1018))
- What is printed? python print(round(1.005, 2), round(0.285, 2), round(1.45, 1))
- What is printed? python print('abcdef'[4:1:-2], 'abc'[::-2], 'abc'[-5:], 'abc'[5:] == '')
- What is printed? python import cmath print((-1) 0.5 == 1j, -1 0.5, (-1) 0.5)