实现进制转化伪代码(修正版)

newBase = eval(input("请输入进制类型"))
decimalNumber = eval(input("请输入数据"))
quotient = 1
answer = ''
list = {'10': 'A', '11': 'B', '12': 'C', '13': 'D', '14': 'E', '15': 'F'}
while quotient != 0:
quotient = decimalNumber // newBase
reminders = str(decimalNumber % newBase)
if reminders in list:
reminders = list[reminders]
answer = reminders + answer
decimalNumber = quotient
print("结果为", answer)

posted @ 2020-11-05 19:41  油菜园12号  阅读(135)  评论(0编辑  收藏  举报