ProgrammingHardTCS NQT · Accenture
What is printed?
What is printed?
x = 0xFF print(x >> 4, x & 0xF0, x ^ 0x0F, ~x & 0xFF)
- A. 15 240 15 0
- B. 15 240 240 255
- C. 15 241 240 0
- D. 15 240 240 0
Correct answer: D. 15 240 240 0
Shifting 0xFF right by four gives 15, and the high nibble mask gives 240. XOR with 0x0F clears the low nibble to 240, and ~255 masked to a byte is 0.
More Python Programming questions
- What is printed? python print(int.frombytes((65).tobytes(1, 'big') 3, 'big'), 65 65 65, bytes([65] 3).decode())
- What is printed? python print(max(['10', '9'], key=len), max(['10', '9']), max([10, 9], key=str))
- What is printed? python print(10 == 10.0 and 'a' == 'a', 1 < 2 or 1 / 0)
- What is printed? python print(sum(x for x in range(1, 101) if x % 3 == 0 or x % 5 == 0))
- What is printed? python print(int(float(253)) == 253, float(253 + 1) - 253, (253 + 1) - 253)
- What is printed? python print('a'.join('xyz'), 'xyz'.join(['a']), 'ab'.join(['', '']), ','.join(map(str, [1.0, 2])))