Write a function called calculate that takes 3 values. The first and third values are numbers. The second value is a character. If the character is "+" , "-", "*", or "/", the function will return the result of the corresponding mathematical function on the two numbers. If the string is not one of the specified characters, the function should return null (throw an `ArgumentException` in C#).

Keep in mind, you cannot divide by zero. If an attempt to divide by zero is made, return null (throw an `ArgumentException` in C#)/(None in Python).

Difficulty: EASY
Starter code: def calculate(num1, operation, num2):
	

Solutions:
def calculate(num1, operation, num2):
	try:
		return eval('{} {} {}'.format(num1, operation, num2))
	except (ZeroDivisionError, SyntaxError):
		return None


def calculate(num1, operation, num2):
	ops = {'+': lambda x, y: x + y, '-': lambda x, y: x - y, '*': lambda x, y: x * y, '/': lambda x, y: x / y}
	try:
		return ops[operation](num1, num2)
	except:
		return None


def calculate(num1, operation, num2):
	try:
		return eval(f'{num1}{operation}{num2}')
	except Exception:
		return


def calculate(num1, oper, num2):
	return None if all((oper == '/', num2 == 0)) else {'+': lambda x, y: x + y, '-': lambda x, y: x - y, '/': lambda x, y: x / y, '*': lambda x, y: x * y}.get(oper, lambda x, y: None)(num1, num2)


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

def calculate(num1, operation, num2):
	try:
		return D[operation](num1, num2)
	except (ZeroDivisionError, KeyError):
		return


def calculate(num1, operation, num2):
	if operation == '+':
		c = num1 + num2
		return c
	if operation == '-':
		c = num1 - num2
		return c
	if operation == '*':
		c = num1 * num2
		return c
	if operation == '/':
		if num2 == 0:
			c = None
			return c
		c = num1 / num2
		return c
	else:
		c = None
		return c


from operator import add, sub, mul

def calculate(num1, operation, num2):
	d = {'+': add, '-': sub, '*': mul, '/': lambda a, b: a / b if b else None}
	return d.get(operation, lambda a, b: None)(num1, num2)


def calculate(num1, operation, num2):
	try:
		return eval(str(num1) + operation + str(num2))
	except:
		return None


def calculate(*args):
	try:
		return eval(''.join(map(str, args)))
	except:
		return None


from operator import add, sub, mul, truediv as div
operators = {'+': add, '-': sub, '*': mul, '/': div}

def calculate(n1, op, n2):
	return operators.get(op, lambda m, n: None)(n1, n2) if f'{op}{n2}' != '/0' else None