Friday 24 September 2021

Python: Convert integer to hexa value

‘hex()’ function is used to convert an integer number to a lowercase hexadecimal string prefixed with “0x”.

 

Example

res1 = hex(15)

 

Find the below working application.

 

hex_demo_2.py

res1 = hex(15)
res2 = hex(16)
res3 = hex(17)

print(res1)
print(res2)
print(res3)

 

Output

0xf
0x10
0x11

 

 

 

  

Previous                                                    Next                                                    Home

No comments:

Post a Comment