PEMDAS Violation - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: PEMDAS Violation (/thread-2150.html) |
PEMDAS Violation - Amitoj25 - Feb-22-2017 Sir can u help me with this code print 500/11*2%8 print 500%11*2/8Here the output is 2 & 1 respectively it is violating PEMDAS rule how ? RE: PEMDAS Violation - micseydel - Feb-22-2017 Are you asserting that it's violating PEMDAS and asking how, or asking if it is? Do you expect the outputs to be different? What exactly do you expect? RE: PEMDAS Violation - ichabod801 - Feb-22-2017 Are you concerned that they are not returning fractional values? If so, that's because you're using Python 2.x, where division of integers returns an integer. Try replacing 500 with 500.0. That makes it a float, and the results of the other operators floats as well. |