AvaSmith-CodingSamples / Python / Basic Python Skill Examples / base_five.py
base_five.py
Raw
#Ava Smith
#Smi01868
#CSCI 1133 Section 001
#Assignment 3

#=========================
#Purpose: To take a base ten integer and convert it into a base three integer
#Input paramaters: num, an integer of base ten
#Return: new_num, an string that is a number of base 5
#=========================


def base_five(num):
    new_num = ""
    list = []
    while num != 0:
        list.append(str(num % 5))
        num = num // 5

    list.reverse()
    for x in list:
        new_num += x

    return new_num
        
if __name__ == "__main__":
    print(21, base_five(11))
    print(113, base_five(33))
    print(1044, base_five(149))
    print(1300, base_five(200))