How do order of operations go on Python?

My question looks like this:

  10-7//2*3+1 

I am supposed to solve the equation.

My answer seems to come out as 8 when using PEMDAS:

First its's 2*3 = 6; 10-7//6+1
second = 7//6= 1; 10-1+1
Third = 10-8 = 8;

But when putting it into python, I get a 2. Why is this so?

It seems the programs order is as such:

first: 7//2=3; 10-3*3+1
second: 3*3=9; 10-9+1
third:10-9+1= 2; 2

I don’t get it.

Leave a Comment

tech