Python‎ > ‎keywords‎ > ‎

or


Introduction
In Boolean operation "or", Python tests the veracity of the statement in either arguments.

Syntax
or

Parameters
None

Example 
Here, Python tested that whether a is equal to either of x, y, z value which is true and print("") statement was subject to the if statement.
 >>> x=3
>>> y=8
>>> z=13
>>> if a==x or y or z:
print("Yes, a is equal to either x, or y,or z.")
>>>
Yes, a is equal to either x, or y,or z.
>>> 

__or__
The method return results of three three sets comparison.
>>> set1={4,5,6,7}
>>> set2={6,7,8,9,10}
>>> set3={1,3,5,7} 
>>> set1==set3.__or__(set2==set3)
False
>>>

If statement is deployed to get the alphabets in lower and uppercase through 'or'.
import string
search1=str(input("Type your search: "))
if search1=="alpalphabets" or "English letter" or "letters":
        print(string.ascii_letters)
>>>
Type your search: alphabets
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLM
NOPQRSTUVWXYZ
>>>




Comments