Back to Freecodecamp

Step 3

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

latest912 B
Original Source

--description--

If the number for which you want to find the square root is negative, the code should raise an error as the square root of a negative number is not defined in real numbers.

Remove the pass statement and create an if statement to check if square_target is less than 0.

--hints--

You should remove the pass keyword.

js
({
    test: () => {
        assert.isFalse(runPython(`_Node(_code).find_function("square_root_bisection").has_pass()`))
    }
})

You should create an if statement to check if square_target < 0.

js
({
    test: () => {
       assert.isFalse(runPython(`_Node(_code).find_function("square_root_bisection").find_if("square_target < 0").is_empty()`))

    }
})

--seed--

--seed-contents--

py
--fcc-editable-region--
def square_root_bisection(square_target, tolerance = 1e-7, max_iterations = 100):
    pass
--fcc-editable-region--