import math
def sqrt_newton(num):
x = math.sqrt(num)
y = num / 2.0
count = 1
while abs(y - x) > 0.00000001:
print
count, y
count += 1
b=(y * 1.0) + (1.0 * num) / y
y = b / 2.0000
return str(number)+"的平方根为:"+str(y)
number = int(input("请输入一个整数:"))
print(sqrt_newton(number))
print(math.sqrt(number))
结果: