Python operators: Difference between revisions
From wikinotes
Line 10: | Line 10: | ||
= bitwise operators = | = bitwise operators = | ||
<blockquote> | <blockquote> | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="python"> | ||
x | y | x | y # bitwise or | ||
x ^ y | x ^ y # bitwise exclusive and | ||
x & y | x & y # bitwise and | ||
x << n | x << n # bitwise shift by n bits | ||
x >> n | x >> n # bitwise shift by n bits | ||
~x | ~x # invert bits | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</blockquote><!-- bitwise operators --> | </blockquote><!-- bitwise operators --> |
Revision as of 00:54, 31 July 2021
Equality Greater/Less Than
== / != # equal/not-equal is / is not # same /not-same instance >= / <= # greater/less than
bitwise operators
x | y # bitwise or x ^ y # bitwise exclusive and x & y # bitwise and x << n # bitwise shift by n bits x >> n # bitwise shift by n bits ~x # invert bits