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.

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to