def div_input(): """Divide a and b parameters""" a = int(request.args["a"]) b = int(request.args["b"]) result = div(a, b) return f"<h1>{result}</h1>"
def search_div(): """ same but divides the two numbers """ a = int(request.args["a"]) b = int(request.args["b"]) return str(div(a, b))
def divide_nums(): """Divide parameters a and b""" a = int(request.args.get("a")) b = int(request.args.get("b")) result = div(a, b) return str(result)
def do_div(): """Divide a and b parameters. """ a = int(request.args.get("a")) b = int(request.args.get("b")) result = div(a, b) return str(result)
def run_div(): """divides a by b""" a = int(request.args.get("a")) b = int(request.args.get("b")) res = div(a, b) return str(res)
def div(): '''It takes 2 parameters and divides them >>> 8/2 = 4 ''' a = int(request.args.get("a")) b = int(request.args.get('b')) result = div(a, b) return str(result) # ---------------------------------------- # part 2 would so that we have less routes # operators = { # "add": add, # "sub": sub, # "mult": mult, # "div": div, # } # @app.route("/calc/<oper>") # def do_math(oper): # """Do math on a and b.""" # a = int(request.args.get("a")) # b = int(request.args.get("b")) # result = operators[oper](a, b) # return str(result)
def division(): '''Divide a by b''' a = int(request.args.get('a')) b = int(request.args.get('b')) result = div(a, b) return str(result)
def divide(): a = int(request.args.get('a')) b = int(request.args.get('b')) res = operations.div(a, b) return str(res)
def div_nums(): """Divide a by b""" a = int(request.args.get("a")) b = int(request.args.get("b")) return (str(div(a, b)))
def run_div(): '''subtract a from b''' a = int(request.args.get("a")) b = int(request.args.get("b")) result = div(a, b) return str(result)
def div_params(): a = int(request.args.get('a')) b = int(request.args.get('b')) result = div(a, b) return str(result)
def divide(): """this function divides a and b, and if a parameter is missing, the parameter is defaulted to 1""" a = int(request.args.get("a", 1)) b = int(request.args.get("b", 1)) result = div(a, b) return f"<h1>dividing {result}</h1>"
def div_nums(): """divide a and b """ a = int(request.args.get("a")) b = int(request.args.get("b")) result = div(a, b) return str(result)
def div_operation(): """Handle get request and divide a by b""" a = int(request.args.get("a")) b = int(request.args.get("b")) return str(div(a, b))
def division(): """ Handle a division request. a and b are passed in via query string """ try: a_str = request.args["a"] b_str = request.args["b"] except: # either a, b, or both a and b were not in the query string. return build_message_values_missing("div", "divide") try: # a and b should be numeric. int was too restrictive so float was used instead a = float(a_str) b = float(b_str) except: # a and/or b were not numeric and could not get converted. return build_message_values_not_numeric("div", a_str, b_str) try: result = div(a, b) except ZeroDivisionError: return f""" <h1><span style="color: #800000;">Division by 0 . . . really??</span></h1> <p style="font-size: 1.5em;"> Division by 0 is not allowed. Ever. Not even on this jangy website! Please change b from {b_str} to a value that is not 0. </p> """ return f"""
def div_request(): """Handle GET request to divide two numbers""" a = int(request.args["a"]) b = int(request.args["b"]) result = div(a, b) return str(result)
def get_div(): """ Dividing a by b and returns result as the body. """ a = float(request.args["a"]) b = float(request.args["b"]) return str(operations.div(a, b))
def to_div(): """divide a and b params""" a = int(request.args["a"]) b = int(request.args["b"]) result_div = div(a, b) # DO WE ALWAYS HAVE TO STRING THE RESULTS??? return str(result_div)
def div_num(): ''' Divide a and b ''' a = int(request.args.get('a')) b = int(request.args.get('b')) result = div(a, b) return f"<h1>{a} divided by {b} is {result}</h1>"
def _division(a, b): """Calls div() function from operations and returns the result.""" a = int(request.args.get("a")) b = int(request.args.get("b")) division = div(a, b) html = f"<html><body><h1>{a} / {b} is...</h1><h3>{division}</h3></body></html" return str(division)
def dividing(): """Divide a by b.""" a = int(request.args.get("a")) b = int(request.args.get("b")) result = div(a, b) return str(result)
def div_a_and_b(): """handles division functionality""" try: a = int(request.args['a']) b = int(request.args['b']) return str(operations.div(a, b)) except Exception as e: return f"{e}"
def do_div(): """divide a by b""" a = int(request.args.get("a")) b = int(request.args.get("b")) result = div(a,b) return str(result)
def to_div(): """Divide a and b params.""" a = int(request.args.get('a')) b = int(request.args.get('b')) result = div(a, b) return str(result)
def div_query_string_options(): """Handle GET: Divide a and b and return result in body.""" a = int(request.args["a"]) b = int(request.args["b"]) result = op.div(a, b) return f"<h1>The division of a and b is {result}!</h1>"
def calc(operation): a, b = int(request.args['a']), int(request.args['b']) OPERATIONS = { "add": add(a, b), "sub": sub(a, b), "mult": mult(a, b), "div": div(a, b) } return str(OPERATIONS[operation])
def div_nums(): """"Divides a and b""" a = int(request.args["a"]) b = int(request.args["b"]) result = div(a, b) return f"{a} / {b} = {result}"
def math(operation): a = float(request.args["a"]) b = float(request.args["b"]) operations_dict = { 'add': operations.add(a, b), 'sub': operations.sub(a, b), 'mult': operations.mult(a, b), 'div': operations.div(a, b) } return str(operations_dict[operation])
def math_funcs(oper): a = int(request.args['a']) b = int(request.args['b']) ops = { 'add': operations.add(a, b), 'sub': operations.sub(a, b), 'mult': operations.mult(a, b), 'div': operations.div(a, b), } return str(ops[oper])
def math_task(task): """perform add, sub, mult, div using math route""" a = int(request.args["a"]) b = int(request.args["b"]) task_dict = { "add": add(a, b), "sub": sub(a, b), "mult": mult(a, b), "div": div(a, b) } op_func = task_dict[task] return str(op_func)
def make_bottom_hist(cnv_wrp, kws): if not bottom_plot_canv_ok(cnv_wrp): return cnv_wrp par = dict(settings.defaults_BottomPlot) par.update(outer_kws) par.update(kws) cnv_wrp._par_mk_ratio_plot_func = par rnds = cnv_wrp._renderers div_wrp = op.div(bottom_plot_get_div_hists(rnds)) div_wrp.histo.SetYTitle(par['y_title'] or ( '#frac{Data}{MC}' if rnds[1].is_data else 'Ratio')) cnv_wrp.bottom_hist = div_wrp.histo settings.set_bottom_plot_general_style(cnv_wrp.bottom_hist) settings.set_bottom_plot_ratio_style(cnv_wrp.bottom_hist) _bottom_plot_y_bounds(cnv_wrp, cnv_wrp.bottom_hist, par)
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)
def define_bottom_hist(self): rnds = self.renderers wrp = op.div(iter(rnds)) wrp.histo.SetYTitle(self.dec_par["y_title"]) self.bottom_hist = wrp.histo