input: Write a function to calculate the result of an operation between two numbers.
  assert calculate(4, 8, "*") == 32
  assert calculate(10, 5, "+") == 15
  assert calculate(9, 3, "-") == 6
  assert calculate(16, 4, "/") == 4
  assert calculate(7, 2, "^") == "Invalid operator"
output: def calculate(a, b, operator):
      if operator == "*":
          return a * b
      elif operator == "+":
          return a + b
      elif operator == "-":
          return a - b
      elif operator == "/":
          return a / b
      else:
          return "Invalid operator"