Beispiel #1
0
def operations():
    """
    user interface for operations menu
    """
    cmd=op_menu()
    while cmd<>"back":
        if cmd=="add":
            base=validate_base()
            operand1=valid_op(base)
            operand2=valid_op(base)
            print result(convert_from(add(int(base),operand1,operand2)))
        elif cmd=="sub":
            base=validate_base()
            operand1=valid_op(base)
            operand2=valid_op(base)
            print result(convert_from(sub(int(base),operand1,operand2)))
        elif cmd=="mul":
            try:
                base=validate_base()
                operand1=valid_op(base)
                operand2=valid_op(base)
                rez=mul(int(base),operand1,operand2)
            except ValueError,msg:
                print msg
                operations()
            print result(convert_from(rez))
        elif cmd=="div":
            try:
                base=validate_base()
                operand1=valid_op(base)
                operand2=valid_op(base)
                rez=div(base,operand1,operand2)[0]
            except ValueError,msg:
                print msg
                operations()
Beispiel #2
0
def operations():
    """
    user interface for operations menu
    """
    cmd = op_menu()
    while cmd <> "back":
        if cmd == "add":
            base = validate_base()
            operand1 = valid_op(base)
            operand2 = valid_op(base)
            print result(convert_from(add(int(base), operand1, operand2)))
        elif cmd == "sub":
            base = validate_base()
            operand1 = valid_op(base)
            operand2 = valid_op(base)
            print result(convert_from(sub(int(base), operand1, operand2)))
        elif cmd == "mul":
            try:
                base = validate_base()
                operand1 = valid_op(base)
                operand2 = valid_op(base)
                rez = mul(int(base), operand1, operand2)
            except ValueError, msg:
                print msg
                operations()
            print result(convert_from(rez))
        elif cmd == "div":
            try:
                base = validate_base()
                operand1 = valid_op(base)
                operand2 = valid_op(base)
                rez = div(base, operand1, operand2)[0]
            except ValueError, msg:
                print msg
                operations()
Beispiel #3
0
def ui():
    cmd=main_menu()
    while cmd<> "exit":      
        if cmd=="operation":
            operations()
        elif cmd=="conversion":
            conversions()
        else:
            print "No such command"
        cmd=main_menu()
Beispiel #4
0
def ui():
    cmd = main_menu()
    while cmd <> "exit":
        if cmd == "operation":
            operations()
        elif cmd == "conversion":
            conversions()
        else:
            print "No such command"
        cmd = main_menu()
Beispiel #5
0
            print result(convert_from(rez))
        elif cmd=="div":
            try:
                base=validate_base()
                operand1=valid_op(base)
                operand2=valid_op(base)
                rez=div(base,operand1,operand2)[0]
            except ValueError,msg:
                print msg
                operations()
            print result(convert_from(rez))
        elif cmd=="back":
            ui()
        else:
            print "No such command"
            operations()
        cmd=op_menu()

def conv_menu():
    print """                 
                                                     Balogh Andrea
                                                        group 911
              subst - converts a number whith substitution method                 
              successiv - converts a number whith successiv divisoon method
              rapid - converts a number whith rapid conversion method
              inter - converts a number whith intermediare base method
              back - back to main menu
    """
    cmd=raw_input("Give a command: ").strip()
    return cmd
Beispiel #6
0
            print result(convert_from(rez))
        elif cmd == "div":
            try:
                base = validate_base()
                operand1 = valid_op(base)
                operand2 = valid_op(base)
                rez = div(base, operand1, operand2)[0]
            except ValueError, msg:
                print msg
                operations()
            print result(convert_from(rez))
        elif cmd == "back":
            ui()
        else:
            print "No such command"
            operations()
        cmd = op_menu()


def conv_menu():
    print """                 
                                                     Balogh Andrea
                                                        group 911
              subst - converts a number whith substitution method                 
              successiv - converts a number whith successiv divisoon method
              rapid - converts a number whith rapid conversion method
              inter - converts a number whith intermediare base method
              back - back to main menu
    """
    cmd = raw_input("Give a command: ").strip()
    return cmd