ProgrammingVery hardTCS NQT · Accenture
What is printed?
What is printed?
print(7 & ~1, 7 >> 1 << 1, (7 | 8) & 12, 6 ^ 3 ^ 3)
- A. 6 7 12 6
- B. 6 6 12 6
- C. 6 6 8 6
- D. 6 6 12 3
Correct answer: B. 6 6 12 6
Clearing bit 0 of 7 gives 6, and shifting 7 right then left also drops the low bit. XOR with the same value twice cancels it out, so 6 ^ 3 ^ 3 is 6.
More Python Programming questions
- What is printed? python print(sorted([(-1, 'a'), (1, 'b'), (-1, 'c')], key=lambda t: t[0], reverse=True))
- What is printed? python x = 'abc' y = x.upper() z = x.upper().lower() print(y, z == x, x.upper().upper() == y, len(y + z))
- What is printed? python print(int('0009'), float('009.50'), int(' -0 '), str(-0))
- What is printed? python print(len(str(2 64)), str(2 64)[:4], 2 64 % 1000)
- What is printed? python print('%c%c' % (72, 105), chr(0x263A) == 'u263a', ord('A') + 1, chr(ord('a') + 25))
- What is printed? python print(sum(i i for i in range(10)), sum(range(10)) 2 == sum(i 3 for i in range(10)), sum(range(10)) 2)