Skip to content
Built-in Functions

hex()

Convert an integer to a hexadecimal string.

hex(number)

hex() shows an integer in base 16. The result begins with 0x to mark it as hexadecimal.

Parameters

NameDescription
numberAn integer, or an object that defines integer conversion.

Returns

A hexadecimal string beginning with 0x.

Try it

Run it and change it
number = 255
print(hex(number))

Related entries