ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
print(bin(37).count('1'), bin(37)[2:].count('0'), (37).bit_length() - bin(37).count('1'))
  1. A. 3 2 3
  2. B. 3 3 3
  3. C. 3 3 2
  4. D. 4 2 3

Correct answer: B. 3 3 3

37 is 100101 in binary, which has three ones and three zeros. Its bit length is 6, so bit length minus the ones count is also 3.

More Python Programming questions

Exams that ask this topic