Python Practice Example 45
Problem:Calculate the sum of numbers from 1 to 100.
Program analysis:None
Program source code:
Example
#!/usr/bin/python
# -*- coding: UTF-8 -*-
tmp = 0
for i in range(1,101):
tmp += i
print ('The sum is %d' % tmp)
The output of the above example is:
The sum is 5050Other Extensions
Python 100 Examples