Exercise 1 solution import struct for fmt in ("hi", "bhb", "bbh", "qb", "bq"): print(fmt, struct.calcsize("@" + fmt), struct.calcsize("<" + fmt)) print(struct.pack("@bi", 1, 2).hex(" ")) print(struct.pack("" prefix so the layout does not depend on the machine.