Skip to content

Convert decimal to hexadecimal in Python

Advertisements

We can use hex() to convert a given decimal number into its hexadecimal equivalent.

print(hex(1))

#0x1

print(hex(22))

#0x16

print(hex(2312))

#0x908

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.