ProgrammingModerateTCS NQT · Wipro pattern

What is printed?

What is printed?
print('%o' % 8 == oct(8)[2:], '%x' % 255 == hex(255)[2:], bin(5)[2:].zfill(4))
  1. A. True True 0101
  2. B. True False 0101
  3. C. True True 101
  4. D. False True 0101

Correct answer: A. True True 0101

%o and oct() both give octal digits, and %x and hex() both give lowercase hexadecimal digits. bin(5) is 101, which zfill pads to 0101.

More Python Programming questions

Exams that ask this topic