实现进制转化为伪代码

用python实现伪代码的表述

Yourbase = int(input("Please write your new base here:"))
Yournumber = int(input("Please write down your number"))

dict1 = {10: 'A', 11:'B', 12:'C', 13:'D', 14:'E', 15:'F'}
list1 = []

quotient = 1

while quotient != 0:
remainder = Yournumber % Yourbase
quotient = Yournumber // Yourbase

if remainder in dict1:
    remainder = dict1[remainder]
list1.append(remainder)
Yournumber = quotient

print("So the transformed number is:")
list1.reverse()

for i in list1:
print(i, end = " ")

三张图片在一张里

posted @ 2021-11-04 20:26  风雾里  阅读(42)  评论(0编辑  收藏  举报