ProgrammingHardTCS NQT · Infosys

What is printed?

What is printed?
print(bin(0b1011011).count('1'), (0b1011011).bit_count(), 0b1011011 & (0b1011011 - 1))
  1. A. 5 5 90
  2. B. 5 5 88
  3. C. 4 5 90
  4. D. 5 4 90

Correct answer: A. 5 5 90

Both ways of counting bits give 5 set bits in 1011011. Clearing the lowest set bit of 91 leaves 90, because the lowest set bit is the 1 in the units place.

More Python Programming questions

Exams that ask this topic