or operator in python code example
Example 1: or statement python
if x==1 or y==1:
print(x,y)
Example 2: operators in python
Operator Name Example
+ Addition x + y
- Subtraction x - y
* Multiplication x * y
/ Division x / y
% Modulus x % y
** Exponentiation x ** y
// Floor division x // y
Example 3: |= operator python
>>> s1 = {"a", "b", "c"}
>>> s2 = {"d", "e", "f"}
>>>
>>> s1 | s2
{'a', 'b', 'c', 'd', 'e', 'f'}
>>> s1
{'a', 'b', 'c'}
>>>
>>> s1 |= s2
>>> s1
{'a', 'b', 'c', 'd', 'e', 'f'}
Example 4: x and y in python
x = 10
y = 12
print('x > y is',x>y)
print('x < y is',x<y)
print('x == y is',x==y)
print('x != y is',x!=y)
print('x >= y is',x>=y)
print('x <= y is',x<=y)
Example 5: or in python
exp1 or exp2
Example 6: logical operators in python
condition1 and condition2
condition1 or condition2
not condition