Python Exercise Example 45
**Problem:** Calculate the sum 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
(
'
The sum is %d
'
%
tmp
)
The output of the above example is:
The sum is 5050
Python 100 Examples