+ 1
Can some one please explain to me how calculations with multiple operators in python are carried out.
Does the law of BODMAS apply or what happens? An example ( 2**6-7%3+2*5/2)
2 ответов
+ 2
MçRìån
Execution order of operators in descending order
()
**
*
/
//
%
+
-
so 64 - 1 + 10 / 2 = 64 - 1 + 5.0 = 69.0 - 1 = 68.0
+ 4
There's more to it. There are additional operators, and some of them have the same precedence (+ and - are equal for example, so they evaluate from left to right)
Full list:
https://www.programiz.com/JUMP_LINK__&&__python__&&__JUMP_LINK-programming/precedence-associativity