Decimal to Hex
Python
Medium
3 views
Problem Description
Read one integer n. Output its lowercase hexadecimal representation without 0x.
Input Format
One integer n.
Output Format
One hex string.
Official Solution
import sys
s=sys.stdin.read().strip()
if not s: sys.exit(0)
n=int(s)
if n==0:
sys.stdout.write('0')
else:
sys.stdout.write(format(n,'x'))
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!