Python Number and Expressions :
The interactive Python interpreter can be used as a powerful calculator.
Try the following : >>> 2 + 2
This should give you the answer 4. That wasn’t too hard.
Well, what about this : >>> 53672 + 235253 = 288925
Still not impressed? Admittedly, this is pretty standard stuff. (I’ll assume that you’ve used
a calculator enough to know the difference between 1+2*3 and (1+2)*3.)
All the usual arith- metic operators work as expected—almost. There is one potential trap here, and that is integer division (in Python versions prior to 3.0) : >>> 1/2 = 0
No comments:
Post a Comment