def fixedPoint(f, epsilon):
"""
f: a function of one argument that returns a float
epsilon: a small float
returns the best guess when that guess is less than epsilon
away from f(guess) or after 100 trials, whichever comes first.
"""
guess = 1.0
for i in range(100):
if f(guess) - guess < epsilon:
return guess
else:
guess = f(guess)
return guess
这个代码有一行是有错误的 但是我有不知道错误在哪里
希望能有大佬帮忙讲解一下
f是一个函数返回一个浮点数
epsilon是一个浮点数
天使之翼死神之镰
慕的地6079101
XO鸡丝
XO鸡丝
相关分类