Switch/Case - Bug Fixing #6

Oh no! Timmy's evalObject function doesn't work. He uses Switch/Cases to evaluate the given properties of an object, can you fix timmy's function?

Source: codewars | Difficulty: EASY

Starter code: def eval_object(v):
	

Solutions:
def eval_object(v):
	return {'+': v['a'] + v['b'], '-': v['a'] - v['b'], '/': v['a'] / v['b'], '*': v['a'] * v['b'], '%': v['a'] % v['b'], '**': v['a'] ** v['b']}.get(v['operation'])


def eval_object(v):
	return eval('{a}{operation}{b}'.format(**v))


def eval_object(v):
	return eval(str(v['a']) + v['operation'] + str(v['b']))


eval_object = lambda v: eval('{}{}{}'.format(v['a'], v['operation'], v['b']))


def eval_object(v):
	return {'+': v['a'] + v['b'], '-': v['a'] - v['b'], '/': v['a'] / v['b'], '*': v['a'] * v['b'], '%': v['a'] % v['b'], '^': 1, '**': v['a'] ** v['b']}[v['operation']]


from operator import add, sub, truediv, mul, mod, pow
ops = {'+': add, '-': sub, '/': truediv, '*': mul, '%': mod, '**': pow}
one = lambda a, b: 1

def eval_object(v):
	return ops.get(v['operation'], one)(v['a'], v['b'])


from typing import Dict, Union

def eval_object(v: Dict[str, Union[str, int]]) -> int:
	return {'+': v['a'] + v['b'], '-': v['a'] - v['b'], '/': v['a'] / v['b'], '*': v['a'] * v['b'], '%': v['a'] % v['b'], '**': v['a'] ** v['b']}.get(v['operation'], 1)


def eval_object(v):
	if v['operation'] == '+':
		return int(v['a']) + int(v['b'])
	elif v['operation'] == '-':
		return int(v['a']) - int(v['b'])
	elif v['operation'] == '/':
		return int(v['a']) / int(v['b'])
	elif v['operation'] == '*':
		return int(v['a']) * int(v['b'])
	elif v['operation'] == '%':
		return int(v['a']) % int(v['b'])
	elif v['operation'] == '**':
		return int(v['a']) ** int(v['b'])


def eval_object(v):
	if v['operation'] == '+':
		c = v['a'] + v['b']
		return c
	if v['operation'] == '-':
		c = v['a'] - v['b']
		return c
	if v['operation'] == '/':
		c = v['a'] / v['b']
		return c
	if v['operation'] == '*':
		c = v['a'] * v['b']
		return c
	if v['operation'] == '%':
		c = v['a'] % v['b']
		return c
	if v['operation'] == '**':
		c = v['a'] ** v['b']
		return c


def eval_object(v):
	return eval('%s %s %s' % (v['a'], v['operation'], v['b']))


def eval_object(v):
	if v['operation'] == '+':
		return v['a'] + v['b']
	elif v['operation'] == '-':
		return v['a'] - v['b']
	elif v['operation'] == '*':
		return v['a'] * v['b']
	elif v['operation'] == '/':
		return v['a'] / v['b']
	elif v['operation'] == '**':
		return v['a'] ** v['b']
	elif v['operation'] == '%':
		return v['a'] % v['b']
	else:
		return 1


def eval_object(v):
	v = list(map(str, v.values()))
	return eval(v[0] + v[2] + v[1])


def eval_object(v):
	c = {'+': v['a'] + v['b'], '-': v['a'] - v['b'], '/': v['a'] / v['b'], '*': v['a'] * v['b'], '%': v['a'] % v['b'], '**': v['a'] ** v['b']}
	if v.get('operation') == '+':
		return v.get('a') + v.get('b')
	elif v.get('operation') == '-':
		return v.get('a') - v.get('b')
	elif v.get('operation') == '*':
		return v.get('a') * v.get('b')
	elif v.get('operation') == '**':
		return v.get('a') ** v.get('b')
	elif v.get('operation') == '/':
		return v.get('a') / v.get('b')
	elif v.get('operation') == '%':
		return v.get('a') % v.get('b')
	else:
		return None


def eval_object(v):
	return {'+': v['a'] + v['b'], '-': int(v['a']) - int(v['b']), '/': int(v['a']) / int(v['b']), '*': int(v['a']) * int(v['b']), '%': int(v['a']) % int(v['b']), '**': int(v['a']) ** int(v['b'])}.get(v['operation'], 1)


def eval_object(v):
	x = {'+': v['a'] + v['b'], '-': v['a'] - v['b'], '/': v['a'] / v['b'], '*': v['a'] * v['b'], '%': v['a'] % v['b'], '**': v['a'] ** v['b']}
	if v['operation'] in x:
		return x.get(v['operation'])


import operator

def eval_object(v):
	ops = {'+': operator.add, '-': operator.sub, '/': operator.truediv, '*': operator.mul, '%': operator.mod, '**': operator.pow}
	return ops.get(v.get('operation'))(v.get('a'), v.get('b'))


def eval_object(v):
	operations = {'+': lambda a, b: a + b, '-': lambda a, b: a - b, '/': lambda a, b: a / b, '*': lambda a, b: a * b, '%': lambda a, b: a % b, '**': lambda a, b: a ** b}
	return operations[v['operation']](v['a'], v['b'])


def eval_object(operation):
	if operation['operation'] == '+':
		x = operation['a'] + operation['b']
	elif operation['operation'] == '-':
		x = operation['a'] - operation['b']
	elif operation['operation'] == '/':
		x = operation['a'] / operation['b']
	elif operation['operation'] == '*':
		x = operation['a'] * operation['b']
	elif operation['operation'] == '%':
		x = operation['a'] % operation['b']
	elif operation['operation'] == '**':
		x = operation['a'] ** operation['b']
	return x


def eval_object(v):
	switcher = {'+': "v['a']+v['b']", '-': "v['a']-v['b']", '/': "v['a']/v['b']", '*': "v['a']*v['b']", '%': "v['a']%v['b']", '**': "v['a']**v['b']"}
	return eval(switcher.get(v['operation']))


def eval_object(v):
	operator = {'+': v['a'] + v['b'], '-': v['a'] - v['b'], '/': v['a'] / v['b'], '*': v['a'] * v['b'], '%': v['a'] % v['b'], '**': v['a'] ** v['b']}
	return operator[v.get('operation', 1)]


def eval_object(v):
	return eval(f"{v['a']}{v['operation']}{v['b']}")


def eval_object(v):
	operations = {'+': v['a'] + v['b'], '-': v['a'] - v['b'], '/': v['a'] / v['b'], '*': v['a'] * v['b'], '%': v['a'] % v['b'], '**': v['a'] ** v['b']}
	return operations.get(v['operation'], 1)


def eval_object(v):
	if v.get('operation') == '+':
		return v.get('a') + v.get('b')
	elif v.get('operation') == '-':
		return v.get('a') - v.get('b')
	elif v.get('operation') == '/':
		try:
			return v.get('a') / v.get('b')
		except ZeroDivisionError:
			return "Can't divide by Zero"
	elif v.get('operation') == '*':
		return v.get('a') * v.get('b')
	elif v.get('operation') == '%':
		return v.get('a') % v.get('b')
	elif v.get('operation') == '**':
		return v.get('a') ** v.get('b')


def eval_object(v):
	return {'+': v['a'] + v['b'], '-': v['a'] - v['b'], '/': v['a'] / v['b'], '*': v['a'] * v['b'], '%': v['a'] % v['b'], '**': v['a'] ** v['b']}.get(v['operation'], 'No operation available')


def eval_object(v):
	a = str(v.get('a'))
	b = str(v.get('b'))
	op = v.get('operation')
	return eval(a + op + b)


def eval_object(v):
	c = v['operation']
	a = v['a']
	b = v['b']
	if c == '+':
		return a + b
	elif c == '-':
		return a - b
	elif c == '/':
		return a / b
	elif c == '*':
		return a * b
	elif c == '%':
		return a % b
	else:
		return a ** b


def eval_object(v):
	x = v.get('a')
	y = v.get('b')
	op = v.get('operation')
	return {'+': x + y, '-': x - y, '/': x / y, '*': x * y, '%': x % y, '**': x ** y}.get(op)


def eval_object(v):
	a = v.get('a')
	b = v.get('b')
	op = v.get('operation')
	if op == '+':
		return a + b
	elif op == '-':
		return a - b
	elif op == '/':
		return a / b
	elif op == '*':
		return a * b
	elif op == '%':
		return a % b
	elif op == '**':
		return a ** b


eval_object = lambda v: eval('%d %s %d' % (v['a'], v['operation'], v['b'])) if v['operation'] in '**%/-+' else 1


def eval_object(v):
	Oper = {'+': lambda a, b: a + b, '-': lambda a, b: a - b, '/': lambda a, b: a / b, '*': lambda a, b: a * b, '%': lambda a, b: a % b, '**': lambda a, b: a ** b}
	return Oper[v['operation']](v['a'], v['b'])


def eval_object(v):
	return {'+': eval("v['a']+v['b']"), '-': v['a'] - v['b'], '/': v['a'] / v['b'], '*': v['a'] * v['b'], '%': v['a'] % v['b'], '**': v['a'] ** v['b']}.get(v['operation'], 1)


eval_object = lambda v: {'+': v['a'] + v['b'], '-': v['a'] - v['b'], '/': v['a'] / v['b'], '*': v['a'] * v['b'], '%': v['a'] % v['b'], '**': v['a'] ** v['b']}.get(v['operation'], 0)


def eval_object(v):
	return {'+': int(v['a']) + int(v['b']), '-': v['a'] - v['b'], '/': v['a'] / v['b'], '*': v['a'] * v['b'], '%': v['a'] % v['b'], '**': v['a'] ** v['b']}[v['operation']]


def eval_object(v):

	def add(d):
		return d['a'] + d['b']

	def subtract(d):
		return d['a'] - d['b']

	def divide(d):
		return d['a'] / d['b']

	def remainder(d):
		return d['a'] % d['b']

	def multiply(d):
		return d['a'] * d['b']

	def double_star(d):
		return d['a'] ** d['b']
	return {'+': add(v), '-': subtract(v), '/': divide(v), '*': multiply(v), '%': remainder(v), '**': double_star(v)}.get(v['operation'])


def eval_object(v):
	switcher = {'+': v['a'] + v['b'], '-': v['a'] - v['b'], '/': v['a'] / v['b'], '*': v['a'] * v['b'], '%': v['a'] % v['b'], '**': v['a'] ** v['b']}
	return switcher.get(v['operation'], 1)


def eval_object(v):
	print(v)
	return {'+': v['a'] + v['b'], '-': v['a'] - v['b'], '/': v['a'] / v['b'], '*': v['a'] * v['b'], '%': v['a'] % v['b'], '**': v['a'] ** v['b']}.get(v['operation'], 0)


import operator

def eval_object(expression):
	mathop = {'+': operator.add, '-': operator.sub, '*': operator.mul, '/': operator.floordiv, '%': operator.mod, '**': operator.pow}
	if not all((isinstance(n, int) for n in (expression['a'], expression['b']))):
		return 0
	else:
		return mathop[expression['operation']](expression['a'], expression['b'])


import operator

def eval_object(v):
	return {'+': operator.add, '-': operator.sub, '/': operator.floordiv, '*': operator.mul, '%': operator.mod, '**': operator.pow}[v['operation']](v['a'], v['b'])


def eval_object(z):
	(a, b, op) = (z[v] for v in ['a', 'b', 'operation'])
	return {'+': a + b, '-': a - b, '/': a / b, '*': a * b, '%': a % b, '**': a ** b}.get(op)


def eval_object(v):
	return eval('{0}{1}{2}'.format(v['a'], v['operation'], v['b']))


def eval_object(v):
	output = {'+': v['a'] + v['b'], '-': v['a'] - v['b'], '/': v['a'] / v['b'], '*': v['a'] * v['b'], '%': v['a'] % v['b'], '**': v['a'] ** v['b']}
	return output[v['operation']]


def eval_object(v):
	(op, a, b) = (v['operation'], v['a'], v['b'])
	return {'+': a + b, '-': a - b, '/': a / b, '*': a * b, '%': a % b, '**': a ** b}.get(op, 1)