问题描述:求 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
问题描述:求 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