Make a Number system convert to convert a number of any number system to another number system. Implement only Binary, Base 5, Octal, Decimal, and Hexa number systems. Converter should be developed in Python language.
M = int(input("Enter number: "))
N = input("Enter the calculus to which the number belongs (2,5,10,8,16): ")
Z = int(input("Enter the base you want to convert the number to (2,5,10,8,16): "))
if Z == 10:
    def any_base_to_decimal(number, base):
        temp = int(number, base)
        print(temp)
    any_base_to_decimal(str(M), int(N))
else:
    def any_base_to_decimal(number, base):
        temp = int(number, base)
        return temp
    pi = any_base_to_decimal(str(M), int(N))
    def dec_to_base(num, base):
        base_num = ""
        while num > 0:
            dig = int(num % base)
            if dig < 10:
                base_num += str(dig)
            else:
                base_num += chr(ord('A') + dig - 10)
            num //= base
        base_num = base_num[::-1]
        print(base_num)
    dec_to_base(pi, Z)
Comments