SunFounder ESP32 Starter Kit
Comparison Operators
Comparison operators are used to compare two values.
Operator Name
== Equal
!= Not equal
< Less than
> Greater than
>= Greater than or equal to
<= Less than or equal to
a = 6
b = 8
print(a>b)
>>> %Run test.py
False
>>>
Return False, beause the a is less than the b.
Logical Operators
Logical operators are used to combine conditional statements.
Operator Description
and Returns True if both statements are true
or Returns True if one of the statements is true
not Reverse the result, returns False if the result is true
a = 6
print(a > 2 and a < 8)
>>> %Run -c $EDITOR_CONTENT
True
>>>
Identity Operators
Identity operators are used to compare the objects, not if they are equal, but if they are actually the same object, with
the same memory location.
Operator Description
is Returns True if both variables are the same object
is not Returns True if both variables are not the same object
302 Chapter 3. For MicroPython User