When looking at a hex representation of an integer in python, the following appears:

>>> hex(7651)
'0x1de3'

How does this storage system work?

1. Convert the integer into its binary representation:

7651 = 0x1110111100011

2. Split the binary into 4-bit blocks:

1
1101
1110
0011

3. Convert each of these 4-bit blocks into hex:

1 = 1
1101 = 13 = d
1110 = 14 = e
0011 = 3

Another example:

>>> hex(987654)
'0xf1206'

987654 = 0b 1111 0001 0010 0000 0110 = f 1 2 0 6