Python编程之求1+2+..100之和

版权声明:此篇博文为博主心血o(╥﹏╥)o,如要转载请注明来源,勿忘心安! https://blog.csdn.net/dyq1995/article/details/88906936

问题描述:求 1 加到 100 之和。

源代码:


#!/usr/bin/python
# -*- coding: UTF-8 -*-
 
tmp = 0
for i in range(1,101):
    tmp += i
print 'The sum is %d' % tmp

输出结果如下:

The sum is 5050

猜你喜欢

转载自blog.csdn.net/dyq1995/article/details/88906936
今日推荐