- Python Programming with Raspberry Pi
- Sai Yamanoor Srihari Yamanoor
- 154字
- 2021-07-02 23:48:43
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 returns True if they are not equal:
>>>3!=2
True
>>>2!=2
False
- GREATER THAN: This operator (>) returns True if one value is greater than the other value:
>>>3>2
True
>>>2>3
False
- LESS THAN: This operator compares two values and returns True if one value is smaller than the other:
>>>2<3
True
>>>3<2
False
- GREATER THAN OR EQUAL TO (>=): This operator compares two values and returns True if one value is greater/bigger than or equal to the other value:
>>>4>=3
True
>>>3>=3
True
>>>2>=3
False
- LESS THAN OR EQUAL TO (<=): This operator compares two values and returns True if one value is smaller than or equal to the other value:
>>>2<=2
True
>>>2<=3
True
>>>3<=2
False
推薦閱讀
- Hands-On Graph Analytics with Neo4j
- 大數據項目管理:從規劃到實現
- HBase Design Patterns
- 自主研拋機器人技術
- 工業機器人操作與編程
- 多媒體制作與應用
- Cloud Security Automation
- 網絡存儲·數據備份與還原
- 生成對抗網絡項目實戰
- Puppet 3 Beginner’s Guide
- 玩機器人 學單片機
- Data Analysis with R(Second Edition)
- Advanced Deep Learning with Keras
- Getting Started with Tableau 2019.2
- Spark Streaming實時流式大數據處理實戰