# coding: utf-8
def get_sqrt(x, a=0.0000001):
x = float(x)
if x < 0:
x = -x
print('我猜你想求的是'+str(x)+'的根号')
x0 = x
while abs(x0**2 - x) > a:
x0 = x0 / 2 + x / (2 * x0)
return x0
y = get_sqrt(2)
print(y)
# coding: utf-8
def get_sqrt(x, a=0.0000001):
x = float(x)
if x < 0:
x = -x
print('我猜你想求的是'+str(x)+'的根号')
x0 = x
while abs(x0**2 - x) > a:
x0 = x0 / 2 + x / (2 * x0)
return x0
y = get_sqrt(2)
print(y)