from sympy import * var(‘x’) g = input ('Enter the function ') function f= lambdify (x , g ) a= float ( input ('Enter a valus :') ) b= float ( input ('Enter b valus :') ) N=int( input ('Enter number of iterations :') ) for i in range (1 , N+1 ): c=( a*f ( b )-b*f ( a ) )/( f ( b )-f ( a ) ) if (( f ( a )*f ( c )): b=c else : a=c print ('itration %d \t the root %0.3f \t function value %0.3f \n'% (i ,c , f ( c ) ) )