input: Write a function to find the closest value to a given number in a given array. The function should return the closest value from the array to the provided number. If the array is empty, the function should return None.
  assert closest_num([5, 4, 8, 7], 5)==5
  assert closest_num([1, 2, 3, 4], 2.6)==3
  assert closest_num([0, 10, 20, 30], 15)==10
  assert closest_num([1], 5)==1
  assert closest_num([], 5)==None
output: def closest_num(arr, num):
      if not arr:
          return None
      closest = arr[0]
      for value in arr:
          if abs(value - num) < abs(closest - num):
              closest = value
      return closest