当前位置:K88软件开发文章中心编程语言PythonPython01 → 文章内容

统计 1 到 100 之和。

减小字体 增大字体 作者:佚名  来源:网上搜集  发布时间:2019-1-6 1:23:23

程序源代码:

实例


#!/usr/bin/python

# -*- coding:
UTF-8 -*-
tmp = 0for i in range(1,101):
tmp += iprint 'The sum is %d' % tmp

以上实例输出结果为:

The sum is 5050

统计 1 到 100 之和。