input: Write a function to calculate the square root of a number using an iterative approach.
  assert square_root(4) == 2.0
  assert square_root(9) == 3.0
  assert square_root(16) == 4.0
output: def square_root(n, tolerance=1e-10):
      if n < 0:
          raise ValueError("Cannot compute the square root of a negative number.")
      guess = n / 2.0
      while True:
          better_guess = (guess + n / guess) / 2.0
          if abs(guess - better_guess) < tolerance:
              return better_guess
          guess = better_guess