Logical Operators in Python – CBSE class 11
Introduction
Hence, the Boolean Logical Operators are those that refers the ways these relationships among values can be connected.
Types of logical operators
Python provides three logical operators to combine existing expressions the list of logical operations is following
-
- and : Returns True if both operands are True.
- or: Returns True if at least one operand is True.
- not : Returns the opposite of the operand’s Boolean value.
1. OR operators :
OR operators combines two or more expressions which makes it operands.
When OR operators has its operands as relation expression (q<p), then or operator performs as following principle.
The OR operators evaluates to true if either of its (relation) operands evaluates to true, otherwise false if both operands evaluate too false.
When or operators has its operands as number / string / list, then operators perform as per following principal.
In an expression x or y, if first operands have false, then return second operands y as result otherwise return x.
2. AND operator :
The AND operator combines two expression which makes it operands
When and operator has its operands as relation expression, then AND operators perform as per the following principal.
The AND operator evaluates to true if both of its relational operands evaluate to true, and evaluates FALSE if both either or both operands evaluate FALSE.
When AND operator has its as number OR string, list then AND operator performs as per following principal.
In expression X&Y, if first operand has FALSE, then return first operand X as result, otherwise return Y.
3. NOT operator:
The Boolean / logical Not operator works on single expression or operand, that means it is a unary operation unlike AND and OR.
Operation that can return string/number/list as result, returns always a Boolean value i.e., TURE or FALSE.
If the expression is false and vice versa.
Exam Time
Chapter : Logical Operators
IMPORTANT QUESTIONS : Asked in examinations of Class 12th Computer Science
Q1. What are Logical Operators in python? |
Q2. What are three logical operators ? |
Q3. what are five logical operators in python? |
Q4. can we use logical operators in strings? |
Q5. What are logical operators used for? |
Q6. How many logical operators are there in python? |
Q7. Write the example of logical operators? |
Q8. which type of operands are permitted with logical operators? |
Read more
- structure of module in python
- arithmetic operators
- operators in python
- types of operators
- logical operators
- membership operators
- standard library module
- Identifiers in python