Given two numbers and an arithmetic operator (the name of it, as a string), return the result of the two numbers having that operator used on them. 

```a``` and ```b``` will both be positive integers, and ```a``` will always be the first number in the operation, and ```b``` always the second.

The four operators are "add", "subtract", "divide", "multiply". 

A few examples: 

``` javascript
ArithmeticFunction.arithmetic(5, 2, "add")      => returns 7
ArithmeticFunction.arithmetic(5, 2, "subtract") => returns 3
ArithmeticFunction.arithmetic(5, 2, "multiply") => returns 10
ArithmeticFunction.arithmetic(5, 2, "divide")   => returns 2
```

Try to do it without using if statements!

Difficulty: introductory

Starter code:

def arithmetic(a, b, operator):
	

Solutions:
def arithmetic(a, b, operator):
    return {
        'add': a + b,
        'subtract': a - b,
        'multiply': a * b,
        'divide': a / b,
    }[operator]

def arithmetic(a, b, operator):
    if operator == "add":
        return a + b
    elif operator == "subtract":
        return a - b
    elif operator == "multiply":
        return a * b
    elif operator == "divide":
        return a / (b * 1.0)

from operator import add, mul, sub, truediv


def arithmetic(a, b, operator):
    ops = {'add': add, 'subtract': sub, 'multiply': mul, 'divide': truediv}
    return ops[operator](a, b)

def arithmetic(a, b, operator):
    if operator == "add":
        return a + b
    elif operator == "subtract":
        return a - b
    elif operator == "multiply":
        return a * b
    elif operator == "divide":
        return a / b
    #your code here


import operator
def arithmetic(a, b, operator_name):
    operators = {
        "add": operator.add,
        "subtract": operator.sub,
        "multiply": operator.mul,
        "divide": operator.truediv
    }
    return operators[operator_name](a,b)

def arithmetic(a, b, operator):
    return a+b if operator=='add' else a-b if operator=='subtract' else a*b if operator=='multiply' else a/b

def arithmetic(a, b, operator):
    op = {
        'add': '+',
        'subtract': '-',
        'multiply': '*',
        'divide': '/'
    }
    return eval("{} {} {}".format(a, op[operator], b))

def arithmetic(a, b, op):
    #your code here
    d={'add':a+b,'subtract':a-b,'multiply':a*b,'divide':a/b,}
    return d[op]

def arithmetic(a, b, operator):
    c = operator
    if c == "add": return a+b
    if c == "subtract": return a-b
    if c == "multiply": return a *b
    if c == "divide": return a / b

def arithmetic(a, b, operator):
    ops = {"add":"+","subtract":"-","multiply":"*","divide":"/"}
    return eval(str(a)+ops[operator]+str(b))

def arithmetic(a, b, operator):
    return {
        'add': lambda a, b: a + b,
        'subtract': lambda a, b: a - b,
        'multiply': lambda a, b: a * b,
        'divide': lambda a, b: a / b
        }[operator](a, b)

def arithmetic(a, b, operator):
    op = {"add":"+", "subtract": "-", "multiply": "*", "divide": "/"}
    return eval(str(a)+op[operator]+str(b))

def arithmetic(a, b, op):
    if op == "add":
        return a+b
    elif op == "subtract":
        return a-b
    elif op == "divide":
        return a/b
    else: 
        return a*b

def arithmetic(a, b, operator):
    return a * b if operator == "multiply" else a / b if operator == "divide" else a + b if operator == "add" else a - b

operators = {
    "add": int.__add__,
    "subtract": int.__sub__,
    "multiply": int.__mul__,
    "divide": int.__truediv__,
}

def arithmetic(a, b, op):
    return operators[op](a, b)

from operator import add, sub, mul, truediv as div

def arithmetic(a, b, operator):
    return {'add': add, 'subtract': sub , 'multiply': mul, 'divide': div}[operator](a, b)

def arithmetic(a, b, operator):
    c = {"add": (a + b), "subtract": (a-b), "multiply": (a * b), "divide": (a/b)}
    return c[operator]

def arithmetic(a, b, operator):
    switcher = {
        'add': a + b,
        'subtract': a - b,
        'multiply': a * b,
        'divide': a / b,
    }
    return switcher[operator]

def arithmetic(a, b, operator):
    ops = {
        'add': lambda a,b: a + b,
        'subtract': lambda a,b: a - b,
        'multiply': lambda a,b: a * b,
        'divide': lambda a,b: a / b}
    return ops[operator](a,b)

import operator

ops = {
    'add': operator.add,
    'subtract': operator.sub,
    'multiply': operator.mul,
    'divide': operator.truediv,
}

def arithmetic(a, b, op):
    return ops[op](a, b)

def arithmetic(a, b, operator):
  if operator == "add": return a+b
  if operator == "subtract": return a-b
  if operator == "multiply": return a*b
  if operator == "divide": return a/b

def arithmetic(a, b, operator):
    dict = {"add": a + b, "subtract": a-b, "multiply": a*b, "divide": a/b}
    return dict[operator]

arithmetic=lambda a,b,o:__import__("operator").__dict__[o[:3].replace('div','truediv')](a,b)

def arithmetic(a, b, operator):
    formats = {
        "add": a+b,
        "subtract": a-b,
        "divide": a/b,
        "multiply": a*b
        }
        
    return formats.get(operator)


from operator import *
def arithmetic(a, b, operator):
    if operator=='add':
        return add(a,b)
    elif operator=='subtract':
        return sub(a,b)
    elif operator=='multiply':
        return mul(a,b)
    elif operator=='divide':
        return truediv(a,b)


def arithmetic(a, b, operator):
     #your code here\
     while operator == 'add':
        return a+b
     while operator == 'subtract':
        return a-b
     while operator == 'multiply':
        return a*b
     while operator == 'divide':
        return a/b

def arithmetic(a, b, operator):
  return eval(f'{a}{operator[0].translate(str.maketrans("asmd", "+-*/"))}{b}')

def arithmetic(a: int, b: int, operator: str) -> int:
    """ Get the result of the two numbers having the operator used on them. """
    return {
        "add": lambda: a + b,
        "subtract": lambda: a - b,
        "multiply": lambda: a * b,
        "divide": lambda: a / b
    }.get(operator)()

def arithmetic(a, b, operator):
    return (lambda a, b, operator:
    (operator == "add" and a + b ) or
    (operator == "subtract" and a - b) or
    (operator == "multiply" and a * b) or
    (operator == "divide" and a / b))(a, b, operator)

def arithmetic(a, b, operator):
    if operator.lower() == "multiply":
        return eval(f"{a}*{b}")
    if operator.lower() == "divide":
        return eval(f"{a}/{b}")
    if operator.lower() == "add":
        return eval(f"{a}+{b}")
    if operator.lower() == "subtract":
        return eval(f"{a}-{b}")

def arithmetic(a, b, operator):
    if operator.lower() == "add":
        return a + b
    elif operator.lower() == "subtract":
        return a - b
    elif operator.lower() == "multiply":
        return a*b
    else:
        return a/b

def arithmetic(a, b, operator):
    if operator == 'add':
        number = a + b
        return number
    elif operator == 'subtract':
        number = a - b
        return number
    elif operator == 'multiply':
        number = a * b
        return number
    elif operator == 'divide':
        number = a / b
        return number

def arithmetic(a, b, operator):
    if operator == "add":
        return (a + b)
    elif operator == "subtract":
        return (a - b)
    elif operator == "multiply":
        return (a * b)
    elif operator == "divide":
        return (a / b)
arithmetic(2,2,"divide")





arithmetic=lambda a,b,s:eval('a%sb'%'-+*/'[ord(s[2])//9-10])

from operator import add, sub as subtract, mul as multiply, truediv as divide
arithmetic = lambda a, b, operator: eval(operator)(a,b)
#DO NOT DO THIS


def arithmetic(a, b, operator):
    return getattr(a, '__' + operator[:3] + '__', a.__truediv__)(b)

arithmetic = lambda a, b, o: eval(str(a)+{'add':'+', 'subtract':'-', 'multiply':'*', 'divide':'/'}[o]+str(b))

from operator import add, sub, mul, truediv, floordiv

div = truediv #floordiv

arithmetic = lambda a, b, s: eval(s[:3])(a, b)

def arithmetic(a, b, operator):
    d = dict()
    d["add"] = '+'
    d["subtract"] = '-'
    d["multiply"] = '*'
    d["divide"] = '/'
    
    return eval('{0} {1} {2}'.format(a, d[operator], b))

def arithmetic(a, b, operator):
    opd = {'add': a+b,'subtract': a-b,'multiply': a*b,'divide': a/b}
    return opd[operator]

def arithmetic(a, b, operator):
    while operator[0] == "a":
        return a + b
        break
    while operator[0] == "s":
        return a - b
        break
    while operator[0] == "m":
        return a * b
        break
    else:
        return a / b


def arithmetic(a, b, operator):
    operators = {'add':'+','subtract':'-','multiply':'*','divide':'/'}
    return eval(str(a)+operators[operator]+str(b))

def arithmetic(a, b, operator):
   return eval('a{}b'.format({'add':'+','subtract':'-','multiply':'*','divide':'/'}[operator]))

def arithmetic(a, b, operator):
    ops = {"add": lambda x,y : x+y,
           "subtract": lambda x,y : x-y,
           "multiply": lambda x,y : x*y,
           "divide": lambda x,y : float(x)/y,
            }
    return ops[operator](a,b)

def arithmetic(a, b, operator):
    return eval(f'{a}{operator}{b}'.replace('add','+').replace('subtract','-').replace('divide','/').replace('multiply','*'))

def arithmetic(a, b, operator):
    op = {'add':'+','subtract':'-','multiply':'*','divide':'/'}
    if b == 0 and operator == 'divide':
        return 'Error! Division by zero!'
    return eval(f'{a} {op[operator]} {b}') if operator in op else 'Error! Wrong operator!'

a={'add':'+',
   'subtract':'-',
   'multiply':'*',
   'divide':'/'}
def arithmetic(b,c,d):
    e=a[str(d)]
    f=str(b)+e+str(c)
    return eval(f)


def arithmetic(a, b, operator):
    if operator=="subtract":
        return a-b
    elif operator=="add":
        return a+b
    elif operator=="multiply":
        return a*b
    elif operator=="divide":
        return a/b

def arithmetic(a, b, operator):
    if operator == "add": return a + b 
    if operator == "multiply": return a * b 
    if operator == "subtract": return a - b 
    return a / b

def arithmetic(a, b, operator):
    try:
        x = {"add":a+b,"subtract":a-b,"divide":a/b,"multiply":a*b}
        return x.get(operator)
    except:
        return None

def arithmetic(a, b, operator):
    arithmetics = {
        "add": a + b,
        "subtract": a - b,
        "multiply": a * b,
        "divide": a / b,
    }
    return arithmetics[operator]

def arithmetic(a, b, operator):
    if operator == 'add':
        return (a+b)
    elif operator == 'subtract':
        return (a-b)
    elif operator == 'multiply':
        return (a*b)
    elif operator == 'divide':
        return (a/b)
    else:
        return ("Unsupport operant")
    #your code here


def arithmetic(a, b, op):
    trans = {
        'add': '+',
        'subtract': '-',
        'divide': '/',
        'multiply': '*'
    }
    if (type(a) == type(b) == int) and (op in trans.keys()):
        return eval(f'{a}{trans[op]}{b}')

def arithmetic(a, b, operator):
    x = [['a','s','m','d'], [a+b,a-b,a*b,a/b]]
    return x[1][x[0].index(operator[0])]


def arithmetic(a, b, operator):
    if operator == "add":
        return a+b
    elif operator == "subtract" :
        return a-b
    elif operator == "multiply":
        return b*a
    else :
        return a/b

def arithmetic(a, b, operator):
    if operator == "add":
        return a + b
    elif operator == "subtract":
        return a - b
    elif operator == "multiply":
        return a * b
    elif operator == "divide":
        return a / b
    else:
        return "I don't know!"

def arithmetic(a, b, operator):
    if operator.lower() == 'add':
        return a+b
    elif operator.lower() == 'subtract':
        return a-b
    elif operator.lower() == 'divide':
        return a/b
    else:
        return a*b

def arithmetic(a, b, operator):
    c=0
    if operator == "add":
        c = a+b
    elif operator == "multiply":
        c= a*b
    elif operator == "divide":
        c = a/b   
    elif operator == "subtract":
        c = a-b
    return c 

def add(a,b):
    return a + b
def subtract(a,b):
    return a - b
def multiply(a,b):
    return a*b
def divide(a,b):
    return a/b

def arithmetic(a, b, operator):
    return eval(operator+'(a,b)')

def arithmetic(a, b, o):
    if o == "add":
        r = a + b
    if o == "subtract":
        r = a - b
    if o == "multiply":
        r = a * b
    if o == "divide":
        r = a / b
    return r

def arithmetic(a, b, operator):
    #your code here
    
    table = {"add": "+", "subtract": "-", "multiply": "*", "divide": "/" }
    
    return eval(str(a) + table[operator] + str(b))

def arithmetic(a, b, operator):
    return eval(f'{a}{ {"add":"+", "subtract":"-", "multiply":"*", "divide":"/"}.get(operator) }{b}')

def arithmetic(a, b, operator):
    if operator == "add":
        return a+b
    elif operator == "subtract":
        return a-b
    elif operator == "multiply":
        return a*b
    elif operator == "divide":
        return a/b
    else:
        return a%b

def arithmetic(a, b, operator):
    if operator == 'add':
        operator = '+'
    elif operator == 'subtract':
        operator = '-'
    elif operator == 'multiply':
        operator = '*'
    elif operator == 'divide':
        operator = '/'
    
    return eval('{}{}{}'.format(a,operator,b))

def arithmetic(a, b, operator):
    #your code here
    words_operator = {
        'add': '+',
        'subtract': '-',
        'multiply': '*',
        'divide': '/'
    }
    
    return(eval("{} {} {}".format(a,words_operator[operator],b)))

def arithmetic(a, b, operator):
    kek = {
        "add": '+',
        "subtract": '-',
        "divide": '/',
        "multiply": '*'
    }
    return eval(f'{a} {kek[operator]} {b}')

def arithmetic(a, b, operator):
    result = 0
    if operator == "add":
        return a + b
    elif operator == "subtract":
        return a - b
    elif operator == "multiply":
        return a * b
    else:
        return a / b

def arithmetic(a, b, operator):
    map = {
        "add": lambda a, b: a + b,
        "subtract": lambda a, b: a - b,
        "multiply": lambda a, b: a * b,
        "divide": lambda a, b: a / b,
    }
    return map[operator](a,b)

def arithmetic(a, b, operator):
    
    if operator == "multiply":
        return a * b
    
    if operator == "add":
        return a + b
    
    if operator == "subtract":
        return a - b
    
    if operator == "divide":
        return a / b

def arithmetic(a, b, operator):
    #your code here
    ans = 0
    if operator == 'add':
        ans = a+b
    elif operator == 'subtract':
        ans = a-b
    elif operator == 'multiply':
        ans = a*b
    elif operator == 'divide':
        ans = a/b
    
    return ans

def arithmetic(a, b, operator):
    calc ={"add":"+", "subtract":"-", "multiply":"*", "divide":"/"}
    return eval(str(a)+calc[operator]+str(b))

import operator as opr
def arithmetic(a, b, operator):
    operations = {
        "add":opr.add,
        "subtract":opr.sub,
        "multiply":opr.mul,
        "divide":opr.truediv
        }
    return operations[operator](a,b)


def arithmetic(a, b, operator):
    if operator == "add":
        return a+b
    elif operator == "subtract":
        return a-b
    elif operator == "multiply":
        return a*b
    elif operator == "divide":
        return a/b
    else:
        return "Please input a proper operator."

import operator as op

f = {
    "add": op.add,
    "subtract": op.sub,
    "multiply": op.mul,
    "divide": op.truediv
}

def arithmetic(a, b, operator):
    return f[operator](a, b)

def arithmetic(a, b, n):
    if n=="add":
        return a+b
    elif n=="subtract":
        return a-b
    elif n=="multiply":
        return a*b
    else:
        return a/b


def arithmetic(a, b, operator):
    operations = {
        'add': lambda x: a+b,
        'subtract':lambda x: a-b,
        'multiply':lambda x: a*b,
        'divide':lambda x: a/b
    }

    return operations[operator](1)

def arithmetic(a, b, operator):
    return operations[operator](a, b)
    
    
    
operations = {
    "add": lambda a, b: a + b,
    "subtract": lambda a, b: a - b,
    "multiply": lambda a, b: a * b,
    "divide": lambda a, b: a / b
}

# No if statements :-)
arithmetic = lambda a, b, o: getattr(__import__("operator"), o == 'divide' and 'itruediv' or o[:3])(a, b)

def arithmetic(a, b, operator):
    total = 0
    if operator == "add":
        total = a+b
    elif operator == "subtract":
        total = a-b
    elif operator == "multiply":
        total = a*b
    elif operator == "divide":
        total = a/b
    else:
        return "Something Went Wrong"
    return total

import operator as o
def arithmetic(a, b, operator):
    ops = {'add': o.add,
          'subtract': o.sub,
           'multiply': o.mul,
           'divide': o.truediv}
    return ops[operator](a,b)

def arithmetic(a, b, op):
    if op == "add":
        return a + b
    elif op == "multiply":
        return a * b
    elif op == "subtract":
        return a - b
    else:
        return a/b

def arithmetic(a, b, operator):
    map_func = {
        'add': lambda a, b: a + b,
        'subtract': lambda a, b: a - b,
        'multiply': lambda a, b: a * b,
        'divide': lambda a, b: a / b
    }
    return map_func[operator](a, b)

def arithmetic(a, b, operator):
    ans= 0
    while operator == "add":
        ans = a+b
        break
    while operator == "subtract":
        ans = a-b
        break
    while operator == "multiply":
        ans = a*b
        break
        
    while operator == "divide":
        ans = a/b
        break
    return ans

def arithmetic(a, b, o):
    res = 0
    if o == 'add':
        res = a + b
    elif o == 'subtract':
        res = a - b
    elif o == 'multiply':
        res = a * b
    elif o == 'divide':
        res = a / b
    else:
        res = 'Please specify operator ... '
    return res

def arithmetic(a, b, operator):
    ops = {
        "add": "__add__",
        "subtract": "__sub__",
        "multiply": "__mul__",
        "divide": "__truediv__"
    }
    return getattr(a, ops[operator])(b)

def arithmetic(a, b, operator):
    if 'add' == operator:
        return a + b
    if 'subtract' == operator:
        return a - b
    if 'multiply' == operator:
        return a * b
    if 'divide' == operator:
        return a / b

def arithmetic(a, b, operator):
    #your code here
    
    if operator=="add":
        result=a+b
    elif operator=="subtract":
        result=a-b
    elif operator=="divide":
        result=a/b
    elif operator=="multiply":
        result=a*b
    else:
        print("You didn't enter an operator or you misspelled the operator.")

    return result

def arithmetic(a, b, operator):
    res = {
        "add": a + b,
        "subtract": a - b,
        "multiply": a * b,
        "divide": a / b
    }
    return res.get(operator, "Invalid operator")

def arithmetic(a, b, operator):
    #Lot of If statements
    if operator == 'add':
        return a +b
    elif operator == 'subtract':
        return a-b
    elif operator == 'multiply':
        return a*b
    else:
        return a/b


from operator import add,sub,mul,truediv as div
def arithmetic(a, b, o):
    return eval(f"{o[:3]}({a},{b})")

def arithmetic(a, b, operator):
    if operator == 'add':
        return a+b
    elif operator == 'subtract':
        return a-b
    elif operator == 'multiply':
        return a*b
    elif operator == 'divide':
        return a/b
    else:
        print('how can I do this better?')



def arithmetic(a, b, operator):
    result=0
    if operator=="add":
        result=a+b
        return result
    elif operator=="subtract":
        result=a-b
        return result
    elif operator=="multiply":
        result=a*b
        return result
    else:
        result=a/b
        return result


def arithmetic(a, b, operator):
    result = 0
    if operator == "add":
        result = a + b
    elif operator == "subtract":
        result = a - b
    elif operator == "multiply":
        result = a * b
    elif operator == "divide":
        result = a / b
    else:
        print("No operator found")
    
    return (result)

def arithmetic(a, b, op):
    return __import__('operator').__dict__['true' * (op[0] == 'd') + op[:3]](a, b)

def arithmetic(a, b, operator):
    if operator == "add":
        return a+b
    if operator == "subtract":
        return a-b
    if operator == "multiply":
        return a*b
    if operator == "divide":
        return a/b
    raise "Can't recognize operator"

def arithmetic(a, b, operator):
    if operator == "add":
        return a + b
    elif operator == "subtract":
        return a - b
    elif operator == "multiply":
        return a * b
    elif operator == "divide":
        return a / b
    
    # simple way which is readable to solve this problem
    # you can use dictionary or one liners also here


def arithmetic(a, b, operator):
    c = ["add", "subtract", "multiply", "divide"]
    d = [a+b, a-b, a*b, a/b]
    n = 0
    while c[0] != operator:
        c.remove(c[0])
        n +=1
    return d[n]

def arithmetic(a, b, operator):
    if operator == 'add' :
       result = a + b
    elif operator == 'subtract':
        result = a - b
    elif operator == 'multiply':
        result = a * b
    elif operator == 'divide':
        result = a / b
    
    return result

result = arithmetic(5, 2, "divide")
print(result)