88 Introduction to Computational Mo de ls with Python
cval = j * 1.25
total = cval + total
j = j + 1
print "Total accumulated: ", total
The following Linux shell command starts the Python interpreter with the
script test4.py.
$ python test4.py
Total accumulated: 131.25
In programming, e ach counter and accumulator variable serves a specific
purpose and these variables should be well documented.
6.2.6 Summation of Input Numbers
The following simple problem applies the concepts and implementation o f
while-loop and a ccumulator variable. The problem computes the summation
of numeric values inputed fr om the main input device. Computing the sum-
mation should proceed while the input values are greater than 1.
The pseudo-code that describes the a lgorithm