- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

In Python, and and or (along with not) are defined as logical operators. Both require two operands which may evaluate to true or false.

The and operator returns True only if both operands are True.

>>> a=50 >>> b=25 >>> a>40 and b>40 False >>> a>100 and b<50 False >>> a==0 and b==0 False >>> a>0 and b>0 True

The or operator returns True if either operand is true.

>>> a=50 >>> b=25 >>> a>40 or b>40 True >>> a>100 or b<50 True >>> a==0 or b==0 False >>> a>0 or b>0 True

- Related Questions & Answers
- What is different in | and OR operators in Python?
- What is different in & and AND operators in Python?
- What is behavior of ++ and -- operators in Python?
- What is the difference between = and == operators in Python?
- What is the difference between the | and || or operators in C#?
- What are different basic operators in Python?
- What are different arithmetic operators in Python?
- What are different operators and expressions used in C language?
- What is difference in Python operators != and "is not"?
- What are different Identity operators types in Python?
- What are different assignment operators types in Python?
- What are different bitwise operators types in Python?
- What is the difference between the != and <> operators in Python?
- What is the difference between | and || operators in c#?
- What is the difference between = and: = assignment operators?

Advertisements