Latest web development tutorials

Python 練習實例45

Python 100例 Python 100例

題目:統計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

Python 100例 Python 100例