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()
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()
def ui(): cmd=main_menu() while cmd<> "exit": if cmd=="operation": operations() elif cmd=="conversion": conversions() else: print "No such command" cmd=main_menu()
def ui(): cmd = main_menu() while cmd <> "exit": if cmd == "operation": operations() elif cmd == "conversion": conversions() else: print "No such command" cmd = main_menu()
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
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