Back to Freecodecamp

Step 2

curriculum/challenges/english/blocks/learn-the-bisection-method-by-finding-the-square-root-of-a-number/65ef190c6b51e9b5a5f7ed29.md

latest1.1 KB
Original Source

--description--

Give the square_root_bisection function the following parameters:

  • square_target: The number for which you want to find the square root.
  • tolerance (optional): The acceptable difference between the square of the approximate root value and the actual target value (default is 1e-7). The tolerance 1e-7 implies that the solution will be accurate to within 0.0000001 of the true value and is a good default choice that balances accuracy and performance.
  • max_iterations (optional): The maximum number of iterations to perform (default is 100). If the method doesn't converge within this limit, you'll assume the solution is not found.

--hints--

Your function should have these parameters: square_target, tolerance = 1e-7, and max_iterations = 100. The order matters.

js
({
    test: () => assert(runPython(`_Node(_code).find_function("square_root_bisection").has_args("square_target, tolerance=1e-7, max_iterations=100")`))
})

--seed--

--seed-contents--

py
--fcc-editable-region--
def square_root_bisection():
    pass
--fcc-editable-region--