python求和编程 如何用python中的for循环实现加法?

如何用python中的for循环实现加法?百度搜索圈t社区免费行业视频教程www.aiquanti.com使用Python的for循环实现算法,如(1,2,3,4,5。。。20) ,代码如下:impo

如何用python中的for循环实现加法?

百度搜索圈t社区免费行业视频教程www.aiquanti.com

使用Python的for循环实现算法,如(1,2,3,4,5。。。20) ,代码如下:

import math

temp=0

对于范围(1,20)中的X:

temp=X

break

else:

print temp

#input result:210

代码示例:

print(”calculate 1,2,3个结果,共100个:“

result=0

对于范围(101)中的I:

result=I

result=result-50

打印(result)