ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(bin(37)[2:].zfill(8), int('100101', 2) == 37)
  1. A. 00100110 True
  2. B. 00100101 True
  3. C. 100101 True
  4. D. 00100101 False

Correct answer: B. 00100101 True

37 is 100101 in binary. zfill pads the digits to eight places, and parsing 100101 in base 2 gives back 37.

More Python Programming questions

Exams that ask this topic