Generally, combination of variables, operators is termed as an expression. To evaluate these type of expressions there is a rule of precedence in Python. 1 is the highest & 13 is the lowest precedence and precedence decreases from left to right.
1. () Parentheses 2. ** Exponent 3. +x, -x, ~x Unary plus, Unary minus, Bitwise NOT 4. *, /, //, % Multiplication, Division, Floor division, Modulus 5. +, - Addition, Subtraction 6. <<, >> Bitwise shift operators 7. & Bitwise AND 8. ^ Bitwise XOR 9. | Bitwise OR 10. ==, !=, >, Comparisions, Identity, Membership operators >=, <, <=, is, is not, in, not in 11. not Logical NOT 12. and Logical AND 13. or Logical OR
>>> print ( 10*9//4 ) Expected outtput : 20 Output Obtained : 22
This page is contributed by Diwas & Sunil . If you like AIHUB and would like to contribute, you can also write an article & mail your article to firstname.lastname@example.org . See your articles appearing on AI HUB platform and help other AI Enthusiast.