How to calculate a file of equations in python

Paul Rubin http
Tue Mar 20 06:19:10 CET 2007

"John" <Allerdyce.John at> writes:
> I have a text file which contains math expression, like this
> 134
> +234
> +234

Erm, is this a homework assignment?  Basicaly you need to identify all
the separate operands and operators and decide what to do with them.
I'm guessing you don't have to worry about operator precedence, for
example the rule that 2+3*5 is treated as 2+(3*5) because * has
precedence over +.  Anyway the idea is keep a running total and
read through the input lines updating the total for each line.

More information about the Python-list mailing list