In this Python online tutorial series, we will study one of the Python built-in functions,Which is Python hex() function.
Use of hex() function in Python
Hex() function is used to convert the integer number to its hexadecimal value.
Syntax of hex() function
- hex is function name.
- x is parameter to hex function.
- x is variable whose hexadecimal value need to be calculated.
Examples of hex() function
below are the few example to illustrate the use of hex function.
# Python hex function example number1=25 print("hexadecimal value of",number1,"is:",hex(number1))
hexadecimal value of 25 is: 0x19
- In above example, number1 is integer having value 25.
- when we apply hex() function on number1, it gave us hexadecimal value which is 0x19.