bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/Python/Foundations
Python•Foundations

Python Bitwise Operators

Flash cards

Review the key moves

1/3
Core idea

What is the main idea behind Python Bitwise Operators?

Lesson checks

Practice each idea before moving on

Short Mimo-style checks built from this lesson's code, terms, and sequence.

1Quick choice

Which statement best captures the main point of this lesson?

Bitwise Operators

Bitwise operators are used to compare (binary) numbers:

OperatorNameDescriptionExample
&ANDSets each bit to 1 if both bits are 1x & y
ORSets each bit to 1 if one of two bits is 1xy
^XORSets each bit to 1 if only one of two bits is 1x ^ y
~NOTInverts all the bits~x
<<Zero fill left shiftShift left by pushing zeros in from the right and let the leftmost bits fall offx << 2
>>Signed right shiftShift right by pushing copies of the leftmost bit in from the left, and let the rightmost bits fall offx >> 2

Previous

Python Membership Operators

Next

Python Operator Precedence