Lecture Notes on 21 Sep 2022 * Complete the following two functions # computes the square root of n, a positive number greater than 1 # using binary search with a precision of 1.0e-6 def sqrt_binary (n): # compute square root of n by making a guess of the square root, say n/2 # and call that guess old_guess, then compute a new_guess of the # square root using the formula: # new_guess = ((n / old_guess) + old_guess) / 2 # then use the formula iteratively until the absolute value of the # difference between old_guess and new_guess is less than 1.0e-6 def sqrt_iter (n): def main(): # test the two functions print (sqrt_binary(2)) print (sqrt_iter(2)) print (2**0.5) main()