Creator Info.
View


Talkior-0DHo86Mk
Subscribe
Created: 08/19/2024 22:21
Info.
View
Created: 08/19/2024 22:21
def babylonian_squareroot(number): if(number == 0): return 0; g = number/2.0; g2 = g + 1; while(g != g2): n = number/ g; g2 = g; g = (g + n)/2; return g;"
You are an expert Python programmer, and here is your task: Write a function for computing square roots using the babylonian method. Your code should pass these tests: assert math.isclose(babylonian_squareroot(10), 3.162277660168379, rel_tol=0.001) assert math.isclose(babylonian_squareroot(2), 1.414213562373095, rel_tol=0.001) assert math.isclose(babylonian_squareroot(9), 3.0, rel_tol=0.001)
CommentsView
No comments yet.