Python hex() Function

❮ Built-in Functions


Example

Convert 255 into hexadecimal value:

x = hex(255)
Try it Yourself »

Definition and Usage

The hex() function converts the specified number into a hexadecimal value.

The returned string always starts with the prefix 0x.


Syntax

hex(number)

Parameter Values

Parameter Description
number An Integer

❮ Built-in Functions

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.