Hex Conversion in Python

Level 115 keystrokes

This converts an integer to its hexadecimal representation using the hex() function.

Python code

# hex() converts an integer to a hexadecimal string starting with 0x
# 255 is ff in hexadecimal, so 0xff is printed
1print(hex(255))

Output

0xff
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this Python code and how often they appear.

  • (× 2
  • )× 2

More Python examples at level 1

← Python typing practice