Python operators: Difference between revisions

From wikinotes
Line 10: Line 10:
= bitwise operators =
= bitwise operators =
<blockquote>
<blockquote>
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="python">
x | y      // bitwise or
x | y      # bitwise or
x ^ y      // bitwise exclusive and
x ^ y      # bitwise exclusive and
x & y      // bitwise and
x & y      # bitwise and
x << n    // bitwise shift by n bits
x << n    # bitwise shift by n bits
x >> n    // bitwise shift by n bits
x >> n    # bitwise shift by n bits
~x        // invert bits
~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