Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PEMDAS Violation
#1
Sir can u help me with this code
print 500/11*2%8
print 500%11*2/8
Here the output is 2 & 1 respectively

it is violating PEMDAS rule how ?
Reply
#2
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?
Reply
#3
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.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Erreur Code access violation reading 0x00000004 yan_mhb 0 2,326 Jul-10-2020, 02:28 PM
Last Post: yan_mhb
  Windows fatal exception: access violation czhhua28 0 5,929 Mar-11-2020, 01:53 AM
Last Post: czhhua28
  Why glGenVertexArray()gives access violation error? hsunteik 4 4,647 May-02-2017, 09:50 AM
Last Post: hsunteik

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020