Added from (up to hexal) to decimal converter
This commit is contained in:
@@ -21,18 +21,13 @@ hextonum = {
|
|||||||
"F": 15
|
"F": 15
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
systypefrom = int(input("Type base number of system convert FROM: "))
|
systypefrom = int(input("Type base number of system convert FROM: "))
|
||||||
systypeto = int(input("Type base number of system convert TO: "))
|
systypeto = int(input("Type base number of system convert TO: "))
|
||||||
convertfrom = input("Type number, that you want to convert: ")
|
|
||||||
if systypefrom > 16 or systypeto > 16:
|
if systypefrom > 16 or systypeto > 16:
|
||||||
print("Sorry, more than hexal systems aren't supported RIGHT NOW. Come back in several centuries")
|
print("Sorry, more than hexal systems aren't supported RIGHT NOW. Come back in several centuries")
|
||||||
input()
|
input()
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
convertfrom = convertfrom.upper()
|
|
||||||
|
|
||||||
def todecimal(number, base):
|
def todecimal(number, base):
|
||||||
n = len(str(number))
|
n = len(str(number))
|
||||||
i = 0
|
i = 0
|
||||||
@@ -43,6 +38,7 @@ def todecimal(number, base):
|
|||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
print(todecimal(convertfrom, systypefrom))
|
while True:
|
||||||
|
inputnumber = input("Type number, that you want to convert: ")
|
||||||
input()
|
inputnumber = inputnumber.upper()
|
||||||
|
print(todecimal(inputnumber, systypefrom))
|
||||||
|
|||||||
Reference in New Issue
Block a user