Krivalar Tutorials
Krivalar Tutorials

# Python - Logical Operators

### <Comparison Operators    Bitwise Operators >

The logical operators are used to evaluate the logical values of their operands in the expression. The Logical operators always return the result as a Boolean value(True or False).

There are three types of logical operators which evaluate the expression.

Operators Meaning Example
or If any of the two expressions is true,
then it returns true.
>>>(10>2)or(3<2)
>>>True
>>>(3>5) or(2==2)
>>>True
and If both expression are true, then it returns true >>>(10>2)or(1<2)
>>>True
>>>(3>5) or(2==2)
>>>False
not If the expression is true, it returns false.
When the expression is false, it returns true.
>>>not(3*4>10)
>>>False
>>>not(5==7)
>>>True

## Logical Operators - Example Program

```>> a=10
>> b=5
>> c=d=20
>> # shows how to use the(or) operator
>> (a>b)or(a>c)
True
>> (a>d)or(a>c)
False
>> # shows how to use the (and) operator
>> (a>b)and(a>c)
False
>> (a>b)and(a<c)
True
>> # shows how to use the (not) operator
>> not(a>c)
True
>> not(3*4>10)
False
>> not(5==7)
True```