Learn the Bisection Method by Finding the Square Root of a Number - Step 2

Hi all! :blush:

I’m trying to write a function to calculate square roots. The requirements are:

  • It should take square_target, tolerance = 1e-7, and max_iterations = 100 as parameters.
  • It should stop when the approximation is within the tolerance or when the max iterations are reached.

Here’s what I have so far:

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

Any tips or examples to help me complete this? Thanks in advance! :pray:



Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0

Challenge Information:

Learn the Bisection Method by Finding the Square Root of a Number - Step 2

Hello @wolli

I have copied and pasted the same Code like yours and it passes the Test. To complete the function you will go trough small steps.

I’m struggling with the same issue ;(

i just did it!!
all you need to do is simply add “pass” after the function definition.
the 1’st function before the one you are declearing, which is the same one, idk why it’s auto duplicated,
i hope this was useful.

hi @MaryaimSHaker , when you need help please open your own topic

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Help button located on the challenge. This button only appears if you have tried to submit an answer at least three times.

The Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.

1 Like

Hi @wolli , I will give it a try for you.
You can define the function using your params instead of pass.
You can run loops to max_iterations and should approach to the result using binary search. Plz let me know if you need any help. :slight_smile: