ProgrammingVery hardJEE Main · CAT placement
What is printed?
What is printed?
x = 12 print(x & -x, x ^ (x - 1), (x & (x - 1)) == 0, -x & x == x & -x)
- A. 4 7 True True
- B. 4 8 False True
- C. 4 7 False True
- D. 12 7 False True
Correct answer: C. 4 7 False True
x & -x isolates the lowest set bit, which is 4. x ^ (x - 1) gives 7 because it flips the trailing bits. In the comparison, & binds tighter than ==, so both sides are the same value, which makes the last check True.
More Python Programming questions
- What is printed? python print((-5).tobytes(2, 'big', signed=True).hex(), int.frombytes(b'xffxfb', 'big', signed=True)…
- What is printed? python import math print(math.fsum([0.1] 10) == 1.0, sum([0.1] 10) == 1.0, math.isqrt(10 30 - 1))
- What is printed? python print(sorted(['pear', 'Fig', 'apple', 'banana', 'kiwi'], key=lambda s: (len(s), s.lower())))
- What is printed? python print(sorted([('b', 1), ('a', 1), ('c', 2)], key=lambda t: t[1], reverse=True))
- What is printed? python print(max(['abc', 'x', 'yz'], key=len), min(['b', 'B', 'a']))
- What is printed? python from decimal import Decimal from fractions import Fraction print(0.1 + 0.2 == 0.3, Decimal('0.1') + Decimal('0.2')…