On 07/31/2015 11:36 AM, Alan Gauld wrote:
On 31/07/15 10:55, Jose Amoreira wrote:
Given the precedence rules already mentioned by Alan and Todd, the
results of the operations you showed us are exactly as expected. You'll
get the same results if you try with a pocket calculator or using any
other programming language or scientific package.
The point I was making is that you may NOT get the same results in any
other language. Each language designer is free to define his/her own
precedence rules. Most try to follow the rules of math, but some do not
(like Lisp using prefix notation rather than infix). Several languages
evaluate purely left to right, at least 1 goes from right to left.
In programming you have to learn the language and not expect it to
conform to any preconceived ideas of how it *should* work.
Yes, you are right, Alan. That expectation is often the source of much
frustration when learning a new language.
But, for this particular application, this particular language even
conforms to those general preconceived ideas... And I'm glad it does!
:)
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor