5.10 Operators
Python uses essentially the same operators as most other programming languages. However, I would like to point out a few special features:
-
DivisionThe / operator always performs floating point division, even if both operands are integers. To perform an integer division, you must use the // operator.
-
Associating assignments with calculationsAssignments can be associated with basic arithmetic operations. In other words, a=a+1 can also be formulated as a+=1. Not only is this short notation allowed for basic arithmetic operations, but for almost all Python operators as well. In contrast to other programming languages, however, a++ and a-- in the sense of a=a+1 and a=a-1 are not allowed.
-
Multiple comparisonsMultiple comparisons ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access