How do order of operations go on Python?

前端 未结 5 1048
庸人自扰
庸人自扰 2020-12-06 06:41

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:

5条回答
  •  暖寄归人
    2020-12-06 07:19

    I think that python doesn’t follow PEMDAS or BODMAS, unless you put the parentheses/brackets around it. So basically I’ll have to mentally do it before writing the program

提交回复
热议问题