- 帖子
- 2
- 精华
- 0
- 积分
- 14
- 阅读权限
- 10
- 注册时间
- 2018-2-7
- 最后登录
- 2018-3-12
|
本帖最后由 留丿白 于 2018-2-7 12:09 编辑
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代表一个浮点数
这个程序有一个错误但是我又不知道怎么修改 求助
|
|