input: Write a function to calculate the mean and median of an array. The function should return both the mean and median values. If the array is empty then return (None, None).
  assert mean_median([10, 15, 20, 25, 30, 35])==(22.5, 22.5)
  assert mean_median([4, 8, 12])==(8.0, 8.0)
  assert mean_median([5, 1, 9, 3, 7])==(5.0, 5.0)
  assert mean_median([])==(None, None)
output: def mean_median(arr):
      if not arr:
          return None, None
      arr.sort()
      mean_val = sum(arr) / len(arr)
      n = len(arr)
      if n % 2 == 0:
          median_val = (arr[n//2 - 1] + arr[n//2]) / 2
      else:
          median_val = arr[n//2]
      return mean_val, median_val