the line
n = n.toString(16);
Is converting the number 11 to a string base 16 or 0xB = 11 decimal.
you can read more about int.toString
the code you want is:
n = 11
n = format(n, 'x')
or
n = hex(n).lstrip('0x')
the lstrip will remove the 0x that is placed when converting to hex