Different Ways to Format and Print Hexadecimal Values in Python
1. Using f-strings (Python 3.6+)
print(f'{15:x}, {15:X}')
f, F
2. Using str.format method
print('{}, {}'.format(format(15, 'x'), format(15, 'X')))
f, F
3. Using format function with placeholders
print('{:x}, {:X}'.format(15, 15))
f, F
4. Using hex function and string slicing
print('{}, {}'.format(hex(15)[2:], hex(15)[2:].upper()))
f, F
5. Using old-style string formatting
print('%x, %X' % (15, 15))
f, F