On 02/07/2016 01:16, DFS wrote:
On 7/1/2016 5:34 AM, Pierre-Alain Dorange wrote:
More reduced :
----------------------------------
u=raw_input('Enter calculation:")
print eval(u)
----------------------------------
works and compute :
1+2+3+4-1+4*2
2+3.0/2-0.5
Perform better and shorter, but less educationnal of course...
2 lines? Love it!
That's not really implementing a calculator. It's just feeding the input
to Python to execute immediately. I can reduce it to zero lines: start
Python so that the >>> prompt appears. Then type in:
>>> 2+3.0/2-0.5
and so on. No other Python code is needed.
--
Bartc
--
https://mail.python.org/mailman/listinfo/python-list