0

Hi friends,

I have written the following program to display a specific o/p:

```
def square_root(a):
if a>1.0:
x=a-1.0
elif a==1.0:
return 1.0
else:
pass
while True:
y=(x+a/x)/2
if math.fabs(y-x)<0.0000001:
break
x=y
return x
import math
i=1.0
while i<=9.0:
print i,
sqrt=square_root(i)
print sqrt,
math_sqrt=math.sqrt(i)
print math_sqrt,
print ''*4,
difference=math_sqrt-sqrt
print math.fabs(difference)
i=i+1
```

The output is to display four columns:

First is 'a' , Second is square root of 'a' by the `square_root(a)`

function I have written , Third is the square root of 'a' my math.sqrt function (inbuilt), the fourth column is to display the absolute value of the difference between column 2 and 3.

The first 3 columns display fine except for the last column. Instead of displaying the difference between the 2 columns, it {strangely} adds up the second and the third columns and finds the absolute.

What is the problem? Kindly help.

Thank You.