-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConverter.py
33 lines (23 loc) · 932 Bytes
/
Converter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import math
print("──────────────────────WELCOME──────────────────────\nThis program converts a number from one base to\nanother\n\n")
def main():
inputNum = input("What number would you like to convert?\n(comma deliniated list)\n")
inputBase = int(input("What base is the number?\n"))
outputBase = int(input("What base do you want?\n"))
inputPlaces = inputNum.split(',')
decimalNumber = int(0)
counter = int(0)
for i in inputPlaces:
decimalNumber += int(inputPlaces[counter]) * (inputBase ** int(counter))
counter += 1
print(decimalNumber)
output = []
while decimalNumber > 0:
temp = decimalNumber
decimalNumber = decimalNumber // outputBase
temp = temp % outputBase
output += [temp]
output.reverse()
print(output)
main()
main()