10进制转16进制 decimal = eval(input("Enter an integer: ")) hexString = "" value = ___(1)___ while value != 0: single = value % 16 if single == 15: hexString = "F" + hexString elif single == 14: hexString = "E" + hexString elif
时间: 2024-04-03 18:30:49 浏览: 137
value = decimal // 16
remainder = decimal % 16
if remainder == 15:
hexString = "F" + hexString
elif remainder == 14:
hexString = "E" + hexString
elif remainder == 13:
hexString = "D" + hexString
elif remainder == 12:
hexString = "C" + hexString
elif remainder == 11:
hexString = "B" + hexString
elif remainder == 10:
hexString = "A" + hexString
else:
hexString = str(remainder) + hexString
decimal = value
print("The hex string is", hexString)
阅读全文