Python hex() function
Python hex() function
The hex() function in Python converts the specified number into a hexadecimal value.
Syntax
hex(x)
Parameter
x: The parameter represents an Integer value.
Return
This function Returns hexadecimal string.
Example 1
# Python Program explaining # the hex() function print("The hexadecimal value of 123: "+ hex(123)) print("The hexadecimal form of a: " + hex(ord('a'))) print("The hexadecimal form of 13.9: "+ float.hex(3.9))
Output
The hexadecimal value of 1230x7b The hexadecimal form of a0x61 The hexadecimal form of 13.9 0x1.f333333333333p+1