import math #
def main():
x = float(input("Enter a positive number: "))
n = int(input("Enter the number of iterations: "))
guess = x/2
for i in range(n):
guess = (guess+x/guess)/2 #迭代计算平方根
e = abs(math.sqrt(x) - guess) #计算猜测值与真实值间误差
print("The guess value is: %f
The error is: %f"%(guess, e))
if e > 0.001: #如果误差过大,则增加迭代次数
print("You may want to increase the number of iterations to get a more accurate value.")