- In python, we have the logical operator.
- "Logical operator" used to perform the different logical operations on the value of variables.
- The logical operators are applicable for boolean and non-boolean types.
- Boolean types are:
- True, False
- non-boolean types are :
- empty string.
- Here True means 1 and Flase means 0.
- There are three different types of logical operators, they are :
- And operator: And operator is used when both arguments are True then the result is True.
- syntax: x and y
Example: write a python code for And operator.
- or operator: or operator is used when at least any one of the arguments is true then the result will be True.
- syntax: x or y
Example: Write a python code using the or operator.
- print(a<3 or b>)
- not operator: not operator is the opposite to the result of an argument, if it is true then the result is False and vice-versa.
- syntax: x not y
Example: write a python code using the not operator.
- print(not x==y)