实现进制转化伪代码

代码

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 on 2021-11-05 12:24  20211417黄琪凯  阅读(23)  评论(0编辑  收藏  举报