Convert an integer number to a lowercase hexadecimal string prefixed with “0x”. If x is not a Python int object, it has to define an __index__() method that returns an integer. Some examples:
hex(x)
>>> hex(255)
'0xff'
>>> hex(-42)
'-0x2a'
>>> '%x' % 255, '%x' % 255, '%X' % 255
('0xff', 'ff', 'FF')
>>> format(255, 'x'), format(255, 'x'), format(255, 'X')
('0xff', 'ff', 'FF')
>>> f'{255:x}', f'{255:x}', f'{255:X}'
('0xff', 'ff', 'FF')