大佬教程收集整理的这篇文章主要介绍了python – 麻省理工学院开放课程,第3讲 – 数学问题,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
根据简单的数学计算,她使用的代码不应该是成功的.
## EXAMPLE: approximate cube root #################### #cube = 27 ##cube = 8120601 ##cube = 10000 #epsilon = 0.1 #guess = 0.0 #increment = 0.01 #num_guesses = 0 ## look for close enough answer and make sure ## didn't accidentally skip the close enough bound #while abs(guess**3 - cubE) >= epsilon and guess <= cube: # guess += increment # num_guesses += 1 #print('num_guesses =',num_guesses) #if abs(guess**3 - cubE) >= epsilon: # print('Failed on cube root of',cube,"with these parameters.") #else: # print(guess,'is close to the cube root of',cubE)
这是她使用的代码,我遇到的问题是理解这部分:
while abs(guess**3 - cubE) >= epsilon and guess <= cube: # guess += increment
如果guess是0.0,cube是27并且increment是0.01那么这个术语的数学应该是:
abs(0**3 - 27) = 27 #----- This is fine according to the code but the next step would be:# abs(27.01**3 - 27) = 19677.878101
这应该阻止循环进一步工作.我的理解在某处显然是@L_673_4@的,但我看不到哪里!
请停下来……
以上是大佬教程为你收集整理的python – 麻省理工学院开放课程,第3讲 – 数学问题全部内容,希望文章能够帮你解决python – 麻省理工学院开放课程,第3讲 – 数学问题所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。