Menu Close

Python hex() Function

In this tutorial, you will all about the Python hex() function to convert specified numbers to hexadecimal.
hex function in Python is the best built-in function to convert numbers to hexadecimal.
In the previous tutorial, we have seen Python hasattr function to check a specified object has a specified attribute or not.

Python hex() function

Python hex() function in python is a built-in function that is used to convert the specified numbers to hexadecimal numbers.

Syntax

The syntax of python hex() function is:-

hex(number)

Parameter

The hex function in python take one parameter, That is number.

Return Value

Return value of hex function in python is converter hexadecimal.

Python hex() Example

Here we will take some examples to understand hex function.

Example 1:

num = 120
print(hex(num))

Output:- 0x78

Conclusion

In this tutorial, you have learned the hex function in python to convert numbers to hexadecimal numbers along with examples.

If this article help you, please share and keep visiting for further python built-in functions tutorials.

Other Python Built-in Functions


For Reference:- Click Here

Python globals() Function
Python object() Function

Related Posts