-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdozenal.py
44 lines (41 loc) · 1.22 KB
/
dozenal.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
34
35
36
37
38
39
40
41
42
43
import math
print("--- Welcome! This is a tool that converts decimal integers to dozenal ---")
while True:
while True:
try:
intDec = int(input("Please enter an interger in decimal:"))
boolbreak = True
except ValueError:
print("Something went wrong.")
boolbreak = False
if abs(intDec) >= 12**10:
print("Too large.")
boolbreak = False
if boolbreak:
break
boolNeg = False
if intDec < 0:
boolNeg = True
intDec = abs(intDec)
strdoz = ""
if boolNeg:
strdoz += "-"
intpow = 9
boolfsf = True
while intpow > -1:
intdigit = (math.floor(intDec/12**intpow))
strdigit = str(intdigit)
if (intdigit != 0) or (not boolfsf) or (intpow == 0):
if intdigit == 10:
strdigit = "X"
if intdigit == 11:
strdigit = "E"
intDec -= intdigit*(12**intpow)
strdoz += strdigit
boolfsf = False
intpow -= 1
print("In dozenal that is " + strdoz +".")
strbreak = input("Would you like to quit? (y/n)")
if strbreak == "y":
break
print("--- Goodbye! ---")