def multiinsertLR_starred_and_co(new, oldL, oldR, l, col): """Inserts new to the left of `oldL` and to the right of `oldR`. NB: Uses a collector func to gather new list and count L, R inserts """ if is_null(l): return col(quote(), 0, 0) if is_atom(car(l)): if is_eq(car(l), oldL): return multiinsertLR_starred_and_co( new, oldL, oldR, cdr(l), lambda newl, L, R: col( cons(new, cons(oldL, newl)), add1(L), R)) if is_eq(car(l), oldR): return multiinsertLR_starred_and_co( new, oldL, oldR, cdr(l), lambda newl, L, R: col( cons(oldR, cons(new, newl)), L, add1(R))) return multiinsertLR_starred_and_co( new, oldL, oldR, cdr(l), lambda newl, L, R: col(cons(car(l), newl), L, R)) return multiinsertLR_starred_and_co( new, oldL, oldR, car(l), lambda carnl, carL, carR: multiinsertLR_starred_and_co( new, oldL, oldR, cdr(l), lambda cdrnl, cdrL, cdrR: col( cons(carnl, cdrnl), add(carL, cdrL), add(carR, cdrR))))
def add_pokemon_name(pokemon): try: operations.add(pokemon) except: raise Exception("Could not add pokemon to team") browse_text_variable.set(f"{pokemon.title()} has been added to your team")
def check_validity_action(x): if re.match(r"^a\s+(\"(([\w]+)\s?)+\")\s+(((\(-?\d+,-?\d+\))\s?)\s?)+$", x): operations.add(x) elif re.match(r"^c\s+(\"(([\w]+)\s?)+\")\s+(((\(-?\d+,-?\d+\))\s?)\s?)+$", x): operations.change(x) elif re.match(r"^r\s+(\"(([\w]+)\s?)+\")\s?$", x): operations.remove(x) elif re.match(r"^g\s?$", x): operations.generateGraph() elif re.match(r"\n", x): print('Error: Please input data.') else: print('Error: Input format unrecognised.')
def run_add(): """adds a and b""" a = int(request.args.get("a")) b = int(request.args.get("b")) res = add(a, b) return str(res)
def addition(): '''Add a and b together''' a = int(request.args.get('a')) b = int(request.args.get('b')) result = add(a, b) return str(result)
def addition(): """Adds a and b parameters""" a = int(request.args.get("a")) b = int(request.args.get("b")) result = add(a, b) return str(result)
def add_nums(): """return the sum of a and b parameters""" a = int(request.args.get("a")) b = int(request.args.get("b")) result = add(a, b) return str(result)
def add(): a = request.args["a"] b = request.args["b"] add = operations.add(int(a), int(b)) return str(add)
def add_params(): a = int(request.args.get('a')) b = int(request.args.get('b')) result = add(a, b) return str(result)
def main(): print("Select Operation") print("1.Add") print("2.Subtract") print("3.Multiply") print("4.Divide") print("5.Power") choice = input("Enter Choice(+,-,*,/,^): ") num1 = int(input("Enter first number: ")) num2 = int(input("Enter Second number:")) if choice == '+': print(num1, "+", num2, "=", add(num1, num2)) elif choice == '-': print(num1, "-", num2, "=", subtract(num1, num2)) elif choice == '*': print(num1, "*", num2, "=", multiply(num1, num2)) elif choice == '/': print(num1, "/", num2, "=", divide(num1, num2)) elif choice == '^': print(num1, "^", num2, "=", power(num1, num2)) else: print("Invalid input") main()
def add_request(): """Handle GET request to add two numbers""" a = int(request.args["a"]) b = int(request.args["b"]) result = add(a, b) return str(result)
def add(): a = int(request.args.get('a')) b = int(request.args.get('b')) res = operations.add(a, b) return str(res)
def add_num(): """Add a and b""" a = int(request.args.get("a")) b = int(request.args.get("b")) result = add(a, b) return str(result)
def addition(): """this function adds a and b, and if a parameter is missing, the parameter is defaulted to 0""" a = int(request.args.get("a", 0)) b = int(request.args.get("b", 0)) result = add(a, b) return f"<h1>adding: {result}</h1>"
def run_add(): '''add a and b''' a = int(request.args.get("a")) b = int(request.args.get("b")) result = add(a, b) return str(result)
def do_add(): """adds a to be""" a = int(request.args.get("a")) b = int(request.args.get("b")) result = add(a, b) return str(result)
def add_nums(): """returns sum of a and b""" a = int(request.args.get("a")) b = int(request.args.get("b")) return (str(add(a, b)))
def do_add(): """Add a and b parameters.""" a = int(request.args.get('a')) b = int(request.args.get('b')) result = add(a, b) return str(result)
def add_num(): ''' Add a and b ''' a = int(request.args.get('a')) b = int(request.args.get('b')) result = add(a, b) return f"<h1>{a} + {b} is {result}</h1>"
def add_input(): """Add a and b parameters""" # Convert string to numbers a = int(request.args["a"]) b = int(request.args["b"]) result = add(a, b) return f"<h1>{result}</h1>"
def to_add(): """add a and b params""" a = int(request.args["a"]) b = int(request.args["b"]) result_add = add(a, b) # DO WE ALWAYS HAVE TO STRING THE RESULTS??? return str(result_add)
def _add(a, b): """Calls add() function from operations and returns the result.""" a = int(request.args.get("a")) b = int(request.args.get("b")) addition = add(a, b) html = f"<html><body><h1>{a} + {b} is...</h1><h3>{addition}</h3></body></html" return html
def _value(nexp): if is_eq(op(nexp), _quote("+")): return add(_value(fse(nexp)), (_value(sse(nexp)))) if is_eq(op(nexp), _quote("x")): return multiply(_value(fse(nexp)), (_value(sse(nexp)))) return expon(_value(fse(nexp)), (_value(sse(nexp))))
def add_a_and_b(): """handles add functionality""" try: a = int(request.args['a']) b = int(request.args['b']) return str(operations.add(a, b)) except Exception as e: return f"{e}"
def search_add(): """ handles GET requests with query parameters a and b and then adds the two numbers together""" a = int(request.args["a"]) b = int(request.args["b"]) sum = add(a, b) return str(sum)
def get_add(): """ Add a and b and returns result as the body. """ a = float(request.args["a"]) b = float(request.args["b"]) return str(operations.add(a, b))
def math_add(): """Add a and b parameters.""" a = int(request.args.get("a")) b = int(request.args.get("b")) result = add(a, b) return str(result)
def do_add(): """ add a and b params""" a = int(request.args.get("a")) b = int(request.args.get("b")) result = add(a,b) return str(result)
def add(): '''It take 2 parameter and adds them >>> 4 + 5 = 9 ''' a = int(request.args.get("a")) b = int(request.args.get("b")) result = add(a, b) return str(result)
def sum_query_string_options(): """Handle GET: Add a and b and return result in body.""" a = int(request.args["a"]) b = int(request.args["b"]) result = op.add(a, b) return f"<h1>The sum of a and b is {result}!</h1>"
def ifthen_operate(number_1, number_2): operation = request.args.get('operation') if operation == "addition": return "{}".format(add(number_1, number_2)) elif operation == "subtraction": return "{]".format(subtract(number_1, number_2)) elif operation == "multiplication": return "{}".format(multiply(number_1, number_2)) elif operation == "division": return "{}".format(divide(number_1, number_2)) else: return "Error: need an operation for two numbers. After the url, type 'operation=', then the operation. Operations are: addition, subtraction, multiplication, and division."
import operations as op x, y = 5, 10 print 'Using arguments:', x, y print 'Sum:', op.add(x, y) print 'Difference:', op.sub(arg1=x, arg2=y) print 'Difference again:', op.sub(arg2=x, arg1=y) x, y = 10.0, 0 print 'Using arguments:', x, y print 'Multiplication:', op.mul(x, x) print 'Division:', op.div(y, x) print 'Division:', op.div(x, y)