ProgrammingHardGATE CS · Product-company placement

What is printed?

What is printed?
print(int("12", 8), oct(64), hex(-255), int("z", 36), format(10, "b").zfill(6))
  1. A. 10 0o100 -0xff 35 001010
  2. B. 12 0o100 -0xff 35 001010
  3. C. 10 0100 0x-ff 35 001010
  4. D. 10 0o100 -0xff 36 1010

Correct answer: A. 10 0o100 -0xff 35 001010

'12' in base 8 is 10. oct and hex use 0o and 0x prefixes with a leading minus for negatives. Base 36 uses 0-9 then a-z, so 'z' is 35. format(10, 'b') is '1010', zero-padded to 6.

More Python Programming questions

Exams that ask this topic