Skip to content

Python Function Hex

Quincy Larson edited this page Aug 20, 2016 · 1 revision

Python hex(x)

hex(x) is a built-in function in Python 3 to convert an integer number to a lowercase hexadecimal string prefixed with “0x”.

Argument

This function takes one argument, x, that should be of integer type.

Return

This function returns a lowercase hexadecimal string prefixed with "0x".

Example

print(hex(16))    # prints  0x10
print(hex(-298))  # prints -0x12a
print(hex(543))   # prints  0x21f

🚀 Run Code

Official Documentation

Clone this wiki locally