其他分享
首页 > 其他分享> > 实现进制转化伪代码

实现进制转化伪代码

作者:互联网

代码

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)

代码截图

运行截图



标签:进制,list,代码,reminders,转化,newBase,answer,quotient,decimalNumber
来源: https://www.cnblogs.com/wjdnmx/p/15512651.html