hex()

Built-in FunctionPython 2.0+Intermediate

Converts an integer to a hexadecimal string prefixed with '0x'

Quick Info

Documentation
Official Docs
Python Version
2.0+

Learn by Difficulty

Quick Example

python
print(hex(255))
print(hex(16))
print(hex(-42))

hex() is a built-in function that converts an integer to a hexadecimal string prefixed with '0x'.

Try in Playground

Tags

builtinfunctioncorenumericconversionstring

Related Items