Trying to understand hexadecimal 0x notation in regards to memory locations and sizes in MiB (mebibytes) and KiB (kibibytes). Specifically, in a partition layout table I can see the following columns:
size        hex '0x' notation           
1 MiB       0x0010 0000    
12 MiB      0x00c0 0000
128 KiB     0x0002 0000
But I find it hard to translate/extract the logic to calculate and do the conversions for myself (for example convert from 24 MiB, 125 KiB, 16 MiB, to '0x' hex notation etc.).
Hence, I thought of writing a Python script (as you do) to do the conversions from MiB/KiB to 'Ox' and additions of '0x'. I found this [https://stackoverflow.com/a/8186974/6167676] but I failed to do anything meaningful from it.
To my surprise I could not find something online to help me do the conversions from MiB/KiB to the hex '0x' notation. In Python I found the hex function in an attempt to do basic additions between hex values in the hex '0x' notation:
def hex_add(h1, h2):
    return hex(int(h1, 0) + int(h2, 0))
How can use Python (built-in or not functions) to automatically calculate the conversion from MiB to the hex '0x' notation? Also, is the hex_add adequate to perform additions on '0x' notation? 
Some code examples to demonstrate the conversion and addition in Python would be very useful.
