QuestionQ3

Python Basics

Review this code:

Question Image

What output does it produce?

  • A (1, 0)
  • B (1,)
  • C (256,)
  • D (\x01, \x00)
Explanation

<H unpacks two bytes as a little-endian unsigned 16-bit integer. The bytes \x01\x00 therefore decode to 1, and struct.unpack returns its results in a one-element tuple.

Community Discussion

No comments yet. Be the first to start the discussion!