ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(12 & -12, 12 ^ 12 >> 1)
- A. 4 10
- B. 4 18
- C. 12 10
- D. 4 6
Correct answer: A. 4 10
12 & -12 isolates the lowest set bit, which is 4. Shift binds tighter than ^, so 12 >> 1 is 6 and 12 ^ 6 is 10.
More Python Programming questions
- What is printed? python print(list(map(lambda a, b: a b, [1, 2, 3], [4, 5])))
- What is printed? python print(max([], default=-1), min(range(0), default='e'))
- What is printed? python from itertools import takewhile, dropwhile a = [1, 3, 5, 2, 7, 1] print(list(takewhile(lambda x: x % 2, a))…
- What is printed? python print(next(iter([]), 'none'), next(iter([7])))
- What is printed? python x = 3.14159 print(f'{x:.2f}|{42:>5}|{0.5:%}')
- What is printed? python print(0.1 + 0.2 + 0.3 == 0.6, 0.6 == 0.3 2, 0.3 2 == 0.6)