hex

Full name
hex
Library
Built-in
Syntax

hex(n)

Description

The hex function converts an integer to its hexadecimal representation in text and lowercase format, preceded by the characters "0x".

Parameters
  • n: integer to convert to hexadecimal format
Examples

Several integers, positive and negative, are converted in this example:

Hex function Example of use

 

If the argument is not an integer, the function returns an error of type TypeError:

Hex function Example of use

 

Something similar happens if the argument is a text string, even if it represents an integer:

Hex function Example of use

 

Submitted by admin on Sun, 01/20/2019 - 13:55