dst src 61904 while src rem divmod src 16 dst insert 0123456789abcdef

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
dst = []
src = 61904
while 1:
src, rem = divmod(src, 16)
dst.insert(0,'0123456789abcdef'[rem])
if not src:
break
dst = "".join(dst)
print dst
'f1d0'