- Related Questions & Answers
- Java Boolean operators
- What are different basic operators in Python?
- What are different arithmetic operators in Python?
- 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 are JavaScript Operators
- What are Boolean literals in Java?
- What are Boolean Literals in C++?
- What are operators in JavaScript?
- What are JavaScript Bitwise Operators?
- What are Arithmetic Operators in JavaScript?
- What are Comparison Operators in JavaScript?
- What are Logical Operators in JavaScript?
- What are Assignment Operators in JavaScript?

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

The logical operators and, or and not are also referred to as boolean operators. While and as well as or operator needs two operands, which may evaluate to true or false, not operator needs one operand evaluating to true or false.

Boolean and operator returns true if both operands return 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

Boolean or operator returns true if any one 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

The not operator returns true if its operand is a false expression and returns false if it is true.

>>> a=10 >>> a>10 False >>> not(a>10) True

Advertisements