Esempio n. 1
0
def getDec():
    while (True):
        try:
            printIn('Insert and integer decimal number: ')
            in_ = int(input())  #will raise a ValueError if casting fails
            return in_
        except ValueError:
            printError('You didn\'t enter a number')
Esempio n. 2
0
def getHex():
    while (True):
        try:
            printIn('Insert and integer hexadecimal number: ')
            in_ = input()
            assert checkChars(in_, hexValidChars) == True
            return in_
        except AssertionError:
            printError('This is not an hexadecimal number!')
Esempio n. 3
0
def getBin():
    while (True):
        try:
            printIn('Insert and integer binary number: ')
            in_ = input()
            assert checkChars(in_,
                              binValidChars)  #checks every chars for validity
            return int(in_)  #will raise a ValueError if casting fails
        except AssertionError:
            printError('This is not a boolean number!')
        except ValueError:
            printError('You didn\'t enter a number')
Esempio n. 4
0
def exitMenu():
    while (True):  #Exit menu
        try:
            #print('\n')
            print('________________________________________')
            printIn("Insert '1' to restart or '0' to exit: ")
            in_ = input()  #will raise a ValueError if casting fails
            assert checkChars(in_, ['0', '1'])
            if (int(in_) == 0):
                exit()
            elif (int(in_) == 1):
                break  #restart program
        except AssertionError:
            printError('You didn\'t enter a 0 or 1')
        except ValueError:
            printError('You didn\'t enter a number')
Esempio n. 5
0
def getOct():
    while (True):
        try:
            printIn('Insert and integer octal number: ')
            in_ = input()
            for inputChar in in_:  #checks every chars for validity
                charChecked = False
                for valid in octValidChars:
                    if inputChar == valid:
                        charChecked = True
                        break
                assert charChecked == True
            return int(in_)  #will raise a ValueError if casting fails
        except AssertionError:
            printError('This is not a boolean number!')
        except ValueError:
            printError('You didn\'t enter a number')