+ 1
what is operators [ + - × ÷ % ^ ~ ] precedence in Python?
in what sequence this operators are evaluated? Is it same like other high level programming language (Java)
5 odpowiedzi
+ 2
for python it is just like mathematics, so PEMDAS (Parentheses, Exponents, Multiplication/Division, Addition/Subtraction), in Java i believe the order of the equation is more important than an order of operations such as PEMDAS
0
There's not really a sequence. It all depends on how you use them. I'm not really sure what your asking.
+ works like plus
- x ÷ all work as they should
% Is used to decide and get the remainder
^ to the power of
0
Operator precedence refers to the order in which an expression is calculated. Python, c and java all use the same ordering.
Example:
6 - 2 * 2 = 2 not 8.
Follow the rule BIMDAS:
1. Brackets
2. Indices
3. Multiply/Divide(modulus)
4. Add/Subtract
0
there is no "~".
- 3
no~