ProgrammingVery hardJEE Main · CAT placement

What is printed?

What is printed?
x = 0b10110110
print(format(x, '08b')[::-1], x.bit_count(), x & (x - 1), (x & -x).bit_length())
  1. A. 10110110 5 180 2
  2. B. 01101101 5 180 1
  3. C. 01101101 5 180 2
  4. D. 01101101 4 180 2

Correct answer: C. 01101101 5 180 2

Reversing the eight-bit string gives 01101101. x has five set bits, x & (x - 1) clears the lowest set bit (value 2), and the lowest set bit is 2, which has bit length 2.

More Python Programming questions

Exams that ask this topic