Back to Freecodecamp

Step 5

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

latest743 B
Original Source

--description--

You'll create separate cases for when square_target is 0 or 1.

Begin by creating an if statement to check if square_target is equal to 1.

--hints--

You should create an if statement to check that square_target == 1.

js
({
    test: () => 
    {
        assert(runPython(`_Node(_code).find_function("square_root_bisection").find_ifs()[1].find_conditions()[0].is_equivalent("square_target == 1")`))
    }
})

--seed--

--seed-contents--

py
--fcc-editable-region--
def square_root_bisection(square_target, tolerance=1e-7, max_iterations=100):
    if square_target < 0:
        raise ValueError('Square root of negative number is not defined in real numbers')

--fcc-editable-region--