Logical operators
Logical operators are used to check different conditions and execute the code accordingly. For example, detecting a button interfaced to the Raspberry Pi's GPIO being pressed and executing a specific task as a consequence. Let's discuss the basic logical operators:
- EQUAL: The EQUAL (
==) operator is used to compare if two values are equal:
>>>3==3
True
>>>3==2
False- NOT EQUAL: The NOT EQUAL (
!=) operator compares two values and returnsTrueif they are not equal:
>>>3!=2
True
>>>2!=2
False- GREATER THAN: This operator (
>) returnsTrueif one value is greater than the other value:
>>>3>2
True
>>>2>3
False- LESS THAN: This operator compares two values and returns
Trueif one value is smaller than the other:
>>>2<3
True
>>>3<2
False- GREATER THAN OR EQUAL TO (>=): This operator...