Untitled
unknown
plain_text
4 years ago
1.3 kB
7
Indexable
# Module that converts decimal and Quinary numbers
# Name: Anson Vattakunnel
# Student Number: VTTANS001
# Date: 12 April 2022
def decimal_to_gumatj(dec):
num = []
gumatj = ""
while(dec // 5 > 0): #as long number is divisble by 5 append array by divider
num.append(dec % 5)
dec = dec // 5
num.append(dec)
for i in num[::-1]: #Converts array to string
gumatj += str(i)
return int(gumatj)
def gumatj_to_decimal(gumatj):
gumatj = str(gumatj)
gumatj = gumatj[::-1] #reverses string
dec = []
decimal_num = 0
for i in range(len(gumatj)): #converts by raising the 5 to the power of the i
dec.append((5**i)*int(gumatj[i]))
for j in dec:
decimal_num += int(j)
return decimal_num
def gumatj_add(num1, num2):
num1 = gumatj_to_decimal(num1) #converts to decimal
num2 = gumatj_to_decimal(num2) #converts to decimal
answer = num1 + num2
return decimal_to_gumatj(answer) #returns converted number
def gumatj_multiply(num1, num2):
num1 = gumatj_to_decimal(num1) #converts to decimal
num2 = gumatj_to_decimal(num2) #converts to decimal
answer = num1*num2
return decimal_to_gumatj(answer) #returns converted numberEditor is loading...