Python operators: Difference between revisions

From wikinotes
 
Line 7: Line 7:
</source>
</source>


= Bitwise Operators =
= bitwise operators =
{{ TODO | unfinished }}
<blockquote>
<syntaxhighlight lang="javascript">
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
</syntaxhighlight>
</blockquote><!-- bitwise operators -->

Revision as of 00:51, 31 July 2021

Operators

if ( x = 1 ) :             #regular if statement
if (not( x =1 )) :         #if not statement
if (x = 1) and (y=2) :     #if and statement
if (x > 10) and (x < 20) : #if or statement

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