input: from typing import Union
  
  def evaluate_expression(expr: str) -> Union[int, float]:
      """Evaluate a given string representing a numerical expression and return the result.
  
      >>> evaluate_expression("2 + 2")
      4
      >>> evaluate_expression("10 * 5 - 3")
      47
      >>> evaluate_expression("3.5 * 2")
      7.0
      """
      return eval(expr)
output:     try:
          result = eval(expr)
          if isinstance(result, (int, float)):
              return result
          else:
              raise ValueError("Expression does not evaluate to a number")
      except Exception as e:
          raise ValueError(f"Invalid expression: {e}")