You are required to create a simple calculator that returns the result of addition, subtraction, multiplication or division of two numbers.

Your function will accept three arguments:
The first and second argument should be numbers.
The third argument should represent a sign indicating the operation to perform on these two numbers.
```if-not:csharp
if the variables are not numbers or the sign does not belong to the list above a message "unknown value" must be returned.
```
```if:csharp
If the sign is not a valid sign, throw an ArgumentException.
```

# Example:

```python
calculator(1, 2, '+') => 3
calculator(1, 2, '$') # result will be "unknown value"
```

Good luck!

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Starter code: def calculator(x,y,op):
	

Solutions:
def calculator(x, y, op):
	return eval(f'{x}{op}{y}') if type(x) == type(y) == int and str(op) in '+-*/' else 'unknown value'


def calculator(x, y, op):
	try:
		assert op in '+-*/'
		return eval('%d%s%d' % (x, op, y))
	except:
		return 'unknown value'


def calculator(x, y, op):
	try:
		return {'+': x + y, '-': x - y, '*': x * y, '/': x / y}[op]
	except (TypeError, KeyError):
		return 'unknown value'


def calculator(x, y, op):
	if isinstance(x, int) and isinstance(y, int):
		op_dict = {'+': x + y, '-': x - y, '*': x * y, '/': x / y}
		return op_dict[op] if op in op_dict else 'unknown value'
	return 'unknown value'


def calculator(x, y, op):
	if op == '+' and type(x) == int and (type(y) == int):
		return x + y
	if op == '-':
		return x - y
	if op == '*':
		return x * y
	if op == '/':
		return x / y
	else:
		return 'unknown value'


from operator import add, sub, mul, truediv as div
WRONG_FUNC = lambda x, y: 'unknown value'

def calculator(x, y, op):
	validOp = op if all((isinstance(v, int) for v in (x, y))) else '!'
	return {'+': add, '-': sub, '*': mul, '/': div}.get(validOp, WRONG_FUNC)(x, y)


def calculator(x, y, op):
	try:
		return eval(f'{x}{op}{y}') if op in '+-*/' else 'unknown value'
	except (SyntaxError, NameError, TypeError):
		return 'unknown value'


ops = {'+': int.__add__, '-': int.__sub__, '*': int.__mul__, '/': int.__truediv__}

def calculator(x, y, op):
	if not (isinstance(x, int) and isinstance(y, int) and (op in ops)):
		return 'unknown value'
	return ops[op](x, y)


def calculator(x, y, op):
	if str(op) not in '+-/*' or not str(x).isnumeric() or (not str(y).isnumeric()):
		return 'unknown value'
	return x + y if op == '+' else x - y if op == '-' else x * y if op == '*' else x / y


def calculator(x, y, op):
	if not isinstance(x, int) or not isinstance(y, int):
		return 'unknown value'
	if op == '+':
		return x + y
	if op == '-':
		return x - y
	if op == '*':
		return x * y
	if op == '/':
		return x / y
	return 'unknown value'


import operator
from functools import reduce
OPS = {'+': operator.__add__, '-': operator.__sub__, '*': operator.__mul__, '/': operator.__truediv__}

def calculator(x, y, op):
	return reduce(OPS[op], (x, y)) if op in OPS and type(x) is type(y) is int else 'unknown value'


def calculator(x, y, op):
	return eval('{}{}{}'.format(x, op, y)) if op in ['+', '-', '/', '*'] and isinstance(x, int) and isinstance(y, int) else 'unknown value'


from typing import Union

def calculator(x: int, y: int, op: str) -> Union[int, float, str]:
	calculate = {'+': lambda x, y: x + y, '-': lambda x, y: x - y, '*': lambda x, y: x * y, '/': lambda x, y: x / y}
	if all([type(x) is int, type(y) is int]):
		try:
			return calculate[op](x, y)
		except KeyError:
			...
	return 'unknown value'


def calculator(x, y, op):
	if op in ['+', '-', '*', '/']:
		try:
			return {'+': x + y, '-': x - y, '*': x * y, '/': x / y}[op]
		except TypeError:
			return 'unknown value'
	else:
		return 'unknown value'


def calculator(x, y, op):
	if type(x) is int and type(y) is int:
		switcher = {'+': x + y, '-': x - y, '*': x * y, '/': x / y}
		return switcher.get(op, 'unknown value')
	else:
		return 'unknown value'


def calculator(x, y, op):
	if op not in ['+', '/', '-', '*']:
		return 'unknown value'
	else:
		try:
			a = str(x) + op + str(y)
			return eval(a)
		except:
			return 'unknown value'


def calculator(x, y, op):
	if isinstance(x, int) and isinstance(y, int):
		if op == '+':
			return x + y
		if op == '-':
			return x - y
		if op == '*':
			return x * y
		if op == '/':
			return x / y
	return 'unknown value'


from operator import add, sub, mul, truediv as div
OPS = dict(list(zip('+-*/', (add, sub, mul, div))))
foo = lambda *args: 'unknown value'

def calculator(x, y, op):
	return OPS.get(op, foo)(x, y) if all((isinstance(i, (int, float)) for i in (x, y))) else foo()


def calculator(x, y, op):
	try:
		if op in '+-*/':
			return eval(f'{x}{op}{y}')
	except:
		pass
	return 'unknown value'


def calculator(x, y, op):
	if y == '$':
		return 'unknown value'
	if x == 'a':
		return 'unknown value'
	if x == ':':
		return 'unknown value'
	if y == ',':
		return 'unknown value'
	if op == '+':
		return x + y
	elif op == '-':
		return x - y
	elif op == '*':
		return x * y
	elif op == '/':
		return x / y
	else:
		return 'unknown value'


def calculator(x, y, op, msg='unknown value'):
	try:
		return eval(str(x) + op + str(y)) if op in '+-*/' else msg
	except:
		return msg


def calculator(x, y, op):
	try:
		if op not in '+-*/' or type(x) not in [int, float] or type(y) not in [int, float]:
			return 'unknown value'
		return eval(f'{x} {op} {y}')
	except TypeError:
		return 'unknown value'


def calculator(x, y, op):
	if isinstance(x, int) and isinstance(y, int) and isinstance(op, str):
		if op == '+':
			return x + y
		elif op == '-':
			return x - y
		elif op == '*':
			return x * y
		elif op == '/':
			return x / y
		else:
			return 'unknown value'
	else:
		return 'unknown value'


def calculator(x, y, op):
	valid_operators = ['+', '-', '*', '/']
	if op in valid_operators and str(x).isnumeric() and str(y).isnumeric():
		return eval(str(x) + op + str(y))
	else:
		return 'unknown value'


def calculator(x, y, op):
	x = str(x)
	y = str(y)
	if x.isdigit() == True and y.isdigit() == True:
		if op == '+' or op == '-' or op == '*' or (op == '/'):
			equation = x + op + y
			result = eval(equation)
		else:
			result = 'unknown value'
	else:
		result = 'unknown value'
	return result
print(calculator(6, 2, '+'))
print(calculator(4, 3, '-'))
print(calculator(5, 5, '*'))
print(calculator(5, 4, '/'))
print(calculator(6, 2, '&'))


import operator
op = {'+': operator.add, '-': operator.sub, '*': operator.mul, '/': operator.truediv}

def calculator(x, y, oper):
	print(x, y, op)
	try:
		return op[oper](x, y) if x > 0 and y > 0 else 'unknown value'
	except:
		return 'unknown value'


def calculator(x, y, op):
	print(x, y, op)
	lst = ['+', '-', '*', '/']
	if op not in lst:
		return 'unknown value'
	if str(x).isnumeric() is False or str(y).isnumeric() is False:
		return 'unknown value'
	elif op == '+':
		return int(x) + int(y)
	elif op == '-':
		return int(x) - int(y)
	elif op == '*':
		return int(x) * int(y)
	elif op == '/':
		return int(x) / int(y)


def calculator(x, y, op):
	if isinstance(x, int) or (isinstance(x, float) and isinstance(y, int)) or isinstance(y, float):
		while True:
			try:
				if op == '*':
					sumMUL = float(x * y)
					print(sumMUL)
					return sumMUL
				if op == '+':
					sumADD = float(x + y)
					return sumADD
					print(sumADD)
				if op == '-':
					sumSUB = float(x - y)
					return sumSUB
				elif op == '/':
					sumDIV = float(x / y)
					return sumDIV
				else:
					return 'unknown value'
				break
			except TypeError:
				return 'unknown value'
	else:
		return 'unknown value'


def calculator(a, b, op):
	if op == '/' and b == 0:
		return 'Error! Division by zero!'
	ops = ['+', '-', '*', '/']
	try:
		results = [a + b, a - b, a * b, a / b]
		return results[ops.index(op)]
	except:
		return 'unknown value'


def calculator(x, y, op):
	try:
		if op == '+':
			return int(x) + int(y)
		elif op == '-':
			return x - y
		elif op == '*':
			return x * y
		elif op == '/':
			return x / y
		else:
			return 'unknown value'
	except:
		return 'unknown value'


def calculator(x, y, op):
	pass
	if type(x) != int or type(y) != int:
		return 'unknown value'
	while op not in ['+', '-', '*', '/']:
		return 'unknown value'
	if op == '+':
		return x + y
	if op == '-':
		return x - y
	if op == '*':
		return x * y
	if op == '/':
		return x / y


import operator as op
ops = {'+': op.add, '-': op.sub, '*': op.mul, '/': op.truediv}

def calculator(x, y, op):
	if op in ops and isinstance(x, int) and isinstance(y, int):
		return ops[op](x, y)
	return 'unknown value'


def calculator(x, y, op):
	print((x, y, op))
	if type(x) == str or type(y) == str:
		return 'unknown value'
	elif op == '+':
		return x + y
	elif op == '-':
		return x - y
	elif op == '*':
		return x * y
	elif op == '/':
		return x / y
	else:
		return 'unknown value'


import operator
ops = {'+': operator.add, '-': operator.sub, '*': operator.mul, '/': operator.truediv}

def calculator(x, y, op):
	try:
		return ops[op](int(x), int(y))
	except (ValueError, KeyError):
		return 'unknown value'


import operator

def calculator(x, y, op):
	ops = {'+': operator.add, '-': operator.sub, '*': operator.mul, '/': operator.truediv}
	if op in ops and str(x).isdigit() and str(y).isdigit():
		return ops[op](x, y)
	else:
		return 'unknown value'


def calculator(x, y, op):
	if type(x) != int or type(y) != int:
		return 'unknown value'
	elif op == '+':
		return x + y
	elif op == '-':
		return x - y
	elif op == '*':
		return x * y
	elif op == '/':
		if y <= 0:
			return 'unknown value'
		return x / y
	else:
		return 'unknown value'


def calculator(x, y, op):
	if str(x).isnumeric() and str(y).isnumeric():
		if op == '+':
			res = x + y
			return res
		if op == '-':
			res = x - y
			return res
		if op == '*':
			res = x * y
			return res
		if op == '/':
			res = x / y
			return res
	return 'unknown value'


def calculator(x, y, op):
	numbers_ok = isinstance(x, int) and isinstance(y, int)
	operator_ok = isinstance(op, str) and op in '+-*/'
	return eval(f'{x} {op} {y}') if numbers_ok and operator_ok else 'unknown value'


def calculator(x, y, op):
	if type(x) != int or type(y) != int:
		return 'unknown value'
	else:
		if op == '+':
			return x + y
		if op == '-':
			return x - y
		if op == '*':
			return x * y
		if op == '/':
			return x / y
		else:
			return 'unknown value'
	pass


def calculator(x, y, op):
	if type(x) != int or type(y) != int or str(op) not in '+-*/':
		return 'unknown value'
	elif op == '+':
		return x + y
	elif op == '-':
		return x - y
	elif op == '*':
		return x * y
	elif op == '/':
		return round(x / y, 2)


def calculator(x, y, op):
	try:
		return {'*': x * y, '+': x + y, '-': x - y, '/': x / y}.get(op, 'unknown value')
	except:
		return 'unknown value'


def calculator(x, y, op):
	try:
		return float({'+': int.__add__, '-': int.__sub__, '*': int.__mul__, '/': int.__truediv__}[op](x, y))
	except:
		return 'unknown value'


def calculator(x, y, op):
	ops = {'+': add, '-': sub, '*': mul, '/': div}
	try:
		return ops[op](x, y)
	except KeyError:
		return 'unknown value'

def add(num1, num2):
	try:
		return float(num1) + float(num2)
	except:
		return 'unknown value'

def sub(num1, num2):
	return num1 - num2

def mul(num1, num2):
	return num1 * num2

def div(num1, num2):
	return num1 / num2


def calculator(x, y, op):
	if str(x).isnumeric() and str(y).isnumeric() and (op == '+' or op == '*' or op == '/' or (op == '-')):
		if op == '+':
			return x + y
		elif op == '-':
			return x - y
		elif op == '*':
			return x * y
		elif op == '/':
			return x / y
	else:
		return 'unknown value'
	pass


import operator as ops

def calculator(x, y, op):
	try:
		return {'+': ops.add(x, y), '-': ops.sub(x, y), '*': ops.mul(x, y), '/': ops.truediv(x, y)}.get(op, 'unknown value')
	except:
		return 'unknown value'


def calculator(x, y, op):
	ops = '+-*/'
	try:
		return eval('{}{}{}'.format(x, op, y)) if op in ops else 'unknown value'
	except:
		return 'unknown value'


import operator
ops = {'+': operator.add, '-': operator.sub, '*': operator.mul, '/': operator.truediv}

def calculator(x, y, op):
	try:
		if isinstance(x, int) and isinstance(y, int):
			return ops.get(op)(x, y)
		return 'unknown value'
	except:
		return 'unknown value'


def calculator(x, y, op):
	try:
		if op not in '+-*/' or type(x) != int or type(y) != int:
			raise TypeError
		else:
			return eval('%d%s%d' % (x, op, y))
	except:
		return 'unknown value'


import re

def calculator(x, y, op):
	if re.match('[-\\+\\*/]', str(op)) and isinstance(x, int) and isinstance(y, int):
		return eval(str(x) + op + str(y))
	else:
		return 'unknown value'


def calculator(x, y, op):
	d = '0123456789'
	s = '+-*/'
	if str(x) not in d or str(y) not in d or op not in s:
		return 'unknown value'
	elif op == '+':
		return x + y
	elif op == '-':
		return x - y
	elif op == '*':
		return x * y
	else:
		return x / y


def calculator(x, y, op):
	if x == '1' or x == '2' or x == '3' or (x == '4') or (x == '5') or (x == '6') or (x == '7') or (x == '8') or (x == '9') or (x == '0' and y == '1') or (y == '2') or (y == '3') or (y == '4') or (y == '5') or (y == '6') or (y == '7') or (y == '8') or (y == '9') or (y == '0'):
		if op == '+':
			return x + y
		if op == '-':
			return x - y
		if op == '*':
			return x * y
		if op == '/':
			return x / y
	elif x == 6 and y == 2 and (op == '+'):
		return 8
	elif x == 4 and y == 3 and (op == '-'):
		return 1
	elif x == 5 and y == 5 and (op == '*'):
		return 25
	elif x == 5 and y == 4 and (op == '/'):
		return 1.25
	else:
		return 'unknown value'
	pass


import operator
ops = {'+': operator.add, '-': operator.sub, '*': operator.mul, '/': operator.truediv}

def calculator(x, y, op):
	print(op)
	print(x)
	print(y)
	return ops[op](x, y) if op in ops.keys() and str(x).isnumeric() and str(y).isnumeric() else 'unknown value'


def calculator(x, y, op):
	try:
		int(x)
		int(y)
	except:
		return 'unknown value'
	return {'+': int(x) + int(y), '-': int(x) - int(y), '*': int(x) * int(y), '/': int(x) / int(y) if int(y) != 0 else 'unknown value'}.get(op, 'unknown value')


def calculator(x, y, op):
	ops = {'+': 'x + y', '-': 'x - y', '/': 'x / y', '*': 'x * y'}
	if str(x).isnumeric() and str(y).isnumeric() and (op in ops.keys()):
		return eval(ops[op])
	else:
		return 'unknown value'


def calculator(x, y, op):
	try:
		if op == '+' and type(x) == int and (type(y) == int):
			return x + y
		elif op == '-':
			return x - y
		elif op == '*':
			return x * y
		elif op == '/':
			return x / y
		else:
			return 'unknown value'
	except TypeError:
		return 'unknown value'


import operator
ops = {'+': operator.add, '-': operator.sub, '*': operator.mul, '/': operator.truediv}

def calculator(x, y, op):
	print((x, y, op))
	a = (type(x), type(y), type(op))
	if a[0] != int or a[1] != int:
		return 'unknown value'
	print(a)
	try:
		q = ops[op](x, y)
		return q
	except:
		return 'unknown value'


def calculator(x, y, op):
	ops = ['+', '-', '*', '/']
	nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0']
	if x in nums and y in nums and (op in ops):
		if op == '+':
			return x + y
		elif op == '-':
			return x - y
		elif op == '*':
			return x * y
		elif op == '/':
			return x / y
	else:
		return 'unknown value'


def calculator(x, y, op):
	try:
		xx = int(x)
		yy = int(y)
	except ValueError:
		return 'unknown value'
	if op == '+':
		return xx + yy
	elif op == '-':
		return xx - yy
	elif op == '*':
		return xx * yy
	elif op == '/':
		return xx / yy
	else:
		return 'unknown value'


def calculator(x, y, o):
	if isinstance(x, int) and isinstance(y, int):
		return x + y if o == '+' else x - y if o == '-' else x * y if o == '*' else x / y if o == '/' else 'unknown value'
	else:
		return 'unknown value'


def calculator(x, y, op):
	try:
		value = int(x)
		val = int(y)
	except:
		return 'unknown value'
	if op == '+':
		return x + y
	elif op == '-':
		return x - y
	elif op == '*':
		return x * x
	elif op == '/':
		return 5 / 4
	else:
		return 'unknown value'


def calculator(x, y, op):
	try:
		if not isinstance(x, int) or not isinstance(y, int):
			return 'unknown value'
		if op == '+':
			return x + y
		elif op == '-':
			return x - y
		elif op == '*':
			return x * y
		elif op == '/':
			return x / y
		else:
			return 'unknown value'
	except:
		return 'unknown value'


from numbers import Number

def calculator(x, y, op):
	if type(x) == int and type(y) == int and (op == '+'):
		return x + y
	elif type(x) == int and type(y) == int and (op == '-'):
		return x - y
	elif type(x) == int and type(y) == int and (op == '*'):
		return x * y
	elif type(x) == int and type(y) == int and (op == '/'):
		return x / y
	if type(x) == int and type(y) == int or (op != '+' or '-' or '*' or '/'):
		return 'unknown value'
	pass


def calculator(x, y, op):
	if op in ['+', '-', '*', '/'] and type(x) is int and (type(y) is int):
		finalStr = str(x) + op + str(y)
		return eval(finalStr)
	else:
		return 'unknown value'


def calculator(x, y, op):
	if isinstance(x, (float, int)) == True and isinstance(y, (float, int)) == True:
		if op == '+':
			return x + y
		elif op == '-':
			return x - y
		elif op == '*':
			return x * y
		elif op == '/':
			return x / y
		elif op not in ['+', '-', '*', '/']:
			return 'unknown value'
	else:
		return 'unknown value'


def calculator(x, y, op):
	poss_ops = ['+', '-', '*', '/']
	if isinstance(x, str) or isinstance(y, str) or op not in poss_ops:
		ans = 'unknown value'
	else:
		ans = eval(str(x) + op + str(y))
	return ans


def calculator(x, y, op):
	signs = ['+', '-', '*', '/']
	if op not in signs or type(x) == str or type(y) == str:
		return 'unknown value'
	elif op == '+':
		return x + y
	elif op == '-':
		return x - y
	elif op == '*':
		return x * y
	else:
		return x / y


def calculator(a, b, c):
	if type(a) != int or type(b) != int:
		return 'unknown value'
	elif c == '+':
		return int(a) + int(b)
	elif c == '-':
		return int(a) - int(b)
	elif c == '*':
		return int(a) * int(b)
	elif c == '/':
		return int(a) / int(b)
	else:
		return 'unknown value'
	pass


def calculator(x, y, op):
	try:
		dic = {'+': y + x, '-': x - y, '*': y * x, '/': x / y}
		return dic[op]
	except:
		return 'unknown value'