ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(int.from_bytes(b'\x01\x00', 'big'), int.from_bytes(b'\x01\x00', 'little'))
  1. A. 256 256
  2. B. 1 1
  3. C. 256 1
  4. D. 1 256

Correct answer: C. 256 1

Big-endian reads the first byte as the most significant, so 0x0100 is 256. Little-endian reads the first byte as the least significant, giving 1.

More Python Programming questions

Exams that ask this topic