ScanSkill

hex

This hex() function returns an integer converted into a hexadecimal string.

Syntax

hex(integer)

Here,

  • integer: Required. An integer value to be converted into a hexadecimal string.

Note: To obtain a hexadecimal string representation for a float, you need to use the float.hex() method.

Example

>>> hex(100)
'0x64'
>>> hex(-30)
'-0x1e'
>>> hex(0b11)
'0x3'
>>> hex(0o67)
'0x37''