input: Write a python function to perform basic arithmetic operations based on user input.
  assert calculator('+', 5, 3) == 8
  assert calculator('-', 10, 4) == 6
  assert calculator('*', 7, 6) == 42
  assert calculator('/', 20, 5) == 4
output: def calculator(operator, num1, num2):
      if operator == '+':
          return num1 + num2
      elif operator == '-':
          return num1 - num2
      elif operator == '*':
          return num1 * num2
      elif operator == '/':
          return num1 / num2