Difference between revisions of "Python:Operators"
Jump to navigation
Jump to search
m |
|||
Line 1: | Line 1: | ||
[[Category:Python]] | [[Category:Python]] | ||
Most operators work as usual. | Most operators work as usual. | ||
+ | |||
+ | ==Assignment== | ||
;a / b | ;a / b | ||
Line 28: | Line 30: | ||
;a ^ b | ;a ^ b | ||
:Xor | :Xor | ||
+ | |||
+ | ==Compare== | ||
+ | ;==, >, <, <=, >=, != | ||
+ | :Just as you would expect | ||
+ | |||
+ | ;and or & | ||
+ | :Logical and | ||
+ | ;or or | | ||
+ | :Logical or | ||
+ | |||
+ | ;not | ||
+ | :Negate the result of the next expression |
Revision as of 15:55, 14 March 2018
Most operators work as usual.
Assignment
- a / b
- Divide to floating point (in python2 the result datatype is determined by the arguments datatype i.e. both arguments int => result is int)
- a // b
- Divide to integer (truncated, not rounded)
- a % b
- Modulo
- a ** b
- Power
- a << b
- bit-shift left
- a >> b
- bit-shift right
- a & b
- And
- a | b
- Or
- a ^ b
- Xor
Compare
- ==, >, <, <=, >=, !=
- Just as you would expect
- and or &
- Logical and
- or or |
- Logical or
- not
- Negate the result of the next expression