SunFounder ESP32 Starter Kit
a = ["hello", "welcome"]
b = ["hello", "welcome"]
c = a
print(a is c)
# returns True because z is the same object as x
print(a is b)
# returns False because x is not the same object as y, even if they have the same content
print(a == b)
# returns True because x is equal to y
>>> %Run -c $EDITOR_CONTENT
True
False
True
>>>
Membership Operators
Membership operators are used to test if a sequence is presented in an object.
Operator Description
in Returns True if a sequence with the specified value is present in the object
not in Returns True if a sequence with the specified value is not present in the object
a = ["hello", "welcome", "Goodmorning"]
print("welcome" in a)
>>> %Run -c $EDITOR_CONTENT
True
>>>
Bitwise Operators
Bitwise operators are used to compare (binary) numbers.
Operator Name Description
& AND Sets each bit to 1 if both bits are 1
OR Sets each bit to 1 if one of two bits is 1
^ XOR Sets each bit to 1 if only one of two bits is 1
~ NOT Inverts all the bits
<< Zero fill left shift Shift left by pushing zeros in from the right and let the leftmost bits fall
off
>> Signed right shift Shift right by pushing copies of the leftmost bit in from the left, and let
the rightmost bits fall off
3.6. 1.6 (Optional) MicroPython Basic Syntax 303