input: Write a python function to implement the Newton-Raphson method for finding roots of a function.
  assert abs(newton_raphson(lambda x: x**2 - 4, lambda x: 2*x, 1, 1e-6) - 2) < 1e-6
  assert abs(newton_raphson(lambda x: x**3 - 27, lambda x: 3*x**2, 3, 1e-6) - 3) < 1e-6
  assert abs(newton_raphson(lambda x: x**2 - 9, lambda x: 2*x, 1, 1e-6) - 3) < 1e-6
output: def newton_raphson(f, df, x0, tol):
      x = x0
      while True:
          x_new = x - f(x) / df(x)
          if abs(x_new - x) < tol:
              break
          x = x_new
      return x