+ 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)

9th Jul 2022, 6:36 AM
McRĂŹĂ„n
McRĂŹĂ„n - avatar
2 Answers
+ 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
9th Jul 2022, 6:58 AM
AÍąJ
AÍąJ - avatar
+ 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
9th Jul 2022, 9:24 AM
Tibor Santa
Tibor Santa - avatar