2018-10-12 15:37:13 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								---
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								title: Python Boolean Operations
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								---
							 
						 
					
						
							
								
									
										
										
										
											2018-10-27 00:31:38 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< a  href = 'https://docs.python.org/3/reference/expressions.html #or '  target = '_blank'  rel = 'nofollow' > `or` </ a > , < a  href = 'https://docs.python.org/3/reference/expressions.html #and '  target = '_blank'  rel = 'nofollow' > `and` </ a > , < a  href = 'https://docs.python.org/3/reference/expressions.html #not '  target = '_blank'  rel = 'nofollow' > `not` </ a >  
						 
					
						
							
								
									
										
										
										
											2018-10-12 15:37:13 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< a  href = 'https://docs.python.org/3/library/stdtypes.html #boolean -operations-and-or-not'  target = '_blank'  rel = 'nofollow' > Python Docs - Boolean Operations</ a >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								These are the Boolean operations, ordered by ascending priority:
							 
						 
					
						
							
								
									
										
										
										
											2019-05-13 00:43:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2018-10-12 15:37:13 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								Operation | Result | Notes  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								--------- | ------------------------------------ | -----  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								x or y | if x is false, then y, else x | (1)  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								x and y | if x is false, then x, else y | (2)  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								not x | if x is false, then True, else False | (3)
							 
						 
					
						
							
								
									
										
										
										
											2019-05-13 00:43:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2018-10-12 15:37:13 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								**Notes:**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								1.   This is a short-circuit operator, so it only evaluates the second argument if the first one is False. 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								2.   This is a short-circuit operator, so it only evaluates the second argument if the first one is True. 
						 
					
						
							
								
									
										
										
										
											2018-10-31 20:17:57 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								3.   `not`  has a lower priority than non-Boolean operators, so `not a == b`  is interpreted as `not (a == b)` , and `a == not b`  is a syntax error. 
						 
					
						
							
								
									
										
										
										
											2018-10-12 15:37:13 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								## Examples:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-10-27 00:31:38 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `or`:
  
						 
					
						
							
								
									
										
										
										
											2019-05-13 00:43:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2018-10-27 00:31:38 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    >>> True or False    # Short-circuited at first argument.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    True
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    >>> False or True    # Second argument is evaluated.
							 
						 
					
						
							
								
									
										
										
										
											2018-10-12 15:37:13 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    True
							 
						 
					
						
							
								
									
										
										
										
											2018-10-27 00:31:38 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    >>> False or False   # Second argument is evaluated.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    False
							 
						 
					
						
							
								
									
										
										
										
											2019-05-13 00:43:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2018-10-12 15:37:13 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								### `and`:
  
						 
					
						
							
								
									
										
										
										
											2019-05-20 00:34:23 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2018-12-09 08:23:21 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    >>> True and False    # Second argument is evaluated.
							 
						 
					
						
							
								
									
										
										
										
											2018-10-12 15:37:13 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    False
							 
						 
					
						
							
								
									
										
										
										
											2018-12-09 08:23:21 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    >>> False and True    # Short-circuted at first argument.
							 
						 
					
						
							
								
									
										
										
										
											2018-10-12 15:37:13 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    False
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    >>> True and True     # Second argument is evaluated.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    True
							 
						 
					
						
							
								
									
										
										
										
											2019-05-13 00:43:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```    
							 
						 
					
						
							
								
									
										
										
										
											2018-10-27 00:31:38 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `not`:
  
						 
					
						
							
								
									
										
										
										
											2019-05-13 00:43:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2018-10-27 00:31:38 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    >>> not True
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    False
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    >>> not False
							 
						 
					
						
							
								
									
										
										
										
											2018-10-12 15:37:13 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    True
							 
						 
					
						
							
								
									
										
										
										
											2019-05-13 00:43:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-05-20 00:34:23 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								## How python sees True and False
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								For python `True==1`  and `False==0` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```python
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								1 and False //False
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								0 and 1 //False
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								1 and True //True
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								1 or 0 //True
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-05-13 00:43:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								## Other boolean-operations:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								These are other boolean operations which are not part of the Python language, you will have to define them yourself or use the boolean expression within the parenteses.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Operation | Result | Notes  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								--------- | ------------------------------------ | -----  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								nand ( not (x and y) ) | if x is True, then y, else x | (1) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								nor ( not (x or y) ) | if x is False, then x, else y | (2) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								xor ( not (not (x or y) or (x and y)) ) |  |  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								xnor ( not (x or y) or (x and y) ) |  | 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								**Notes:**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								1.   This is a short-circuit operator, so it only evaluates the second argument if the first one is True. 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								2.   This is a short-circuit operator, so it only evaluates the second argument if the first one is False. 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								## Examples:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### `nand`:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### Used in a defined way:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```python
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    def nand(x, y):
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return not(x and y)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `output`:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    >>> nand(True, True) # Short-circuited at first argument.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    False
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    >>> nand(False, True) # Second argument is evaluated.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    True
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    >>> nand(True, False) # Short-circuited at first argument.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    True
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    >>> nand(False, False) # Second argument is evaluated.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    True
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### Used in a direct way:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```python
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if not(x and y):
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        do something....
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `output`:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    >>> not(True and True): # Short-circuited at first argument.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    False
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    >>> not(True and True) # Second argument is evaluated.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    True
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    >>> not(True and True) # Short-circuited at first argument.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    True
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    >>> not(True and True) # Second argument is evaluated.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    True
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### `nor`:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### Used in a defined way:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```python
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    def nor(x, y):
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return not(x or y)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `output`:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    >>> nor(True, True) # Short-circuited at first argument.
							 
						 
					
						
							
								
									
										
										
										
											2018-12-09 08:23:21 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    False
							 
						 
					
						
							
								
									
										
										
										
											2019-05-13 00:43:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    >>> nor(False, True) # Second argument is evaluated.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    False
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    >>> nor(True, False) # Short-circuited at first argument.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    False
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    >>> nor(False, False) # Second argument is evaluated.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    True
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```   
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### Used in a direct way:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```python
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if nor(x or y):
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        do something....
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `output`:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    >>> not(True or True): # Short-circuited at first argument.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    False
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    >>> not(True or True) # Second argument is evaluated.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    False
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    >>> not(True or True) # Short-circuited at first argument.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    False
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    >>> not(True or True) # Second argument is evaluated.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    True
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```   
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### `xor`:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### Used in a defined way:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```python
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    def xor(x, y):
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return not(not(x or y) or (x and y))
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `output`:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    >>> xor(True, True)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    False
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    >>> xor(False, True)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    True
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    >>> xor(True, False)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    True
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    >>> xor(False, False)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    False
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### Used in a direct way:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```python
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if not(not(x or y) or (x and y)):
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        do something....
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2018-12-09 08:23:21 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-05-13 00:43:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `output`:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    >>> not(not(True or True) or (True and True)): # Short-circuited at first argument.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    False
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    >>> not(not(True or False) or (True and False)) # Second argument is evaluated.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    True
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    >>> not(not(False or True) or (False and True)) # Short-circuited at first argument.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    True
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    >>> not(not(False or False) or (False and False)) # Second argument is evaluated.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    False
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### `xnor`:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### Used in a defined way:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```python
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    def xnor(x, y):
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return not(x or y) or (x and y)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `output`: 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    >>> xnor(True, True)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    True
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    >>> xnor(False, True)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    False
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    >>> xnor(True, False)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    False
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    >>> xnor(False, False)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    True
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### Used in a direct way:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```python
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if not(x or y) or (x and y):
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        do something....
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `output`:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    >>> not(not(True or True) or (True and True)): # Short-circuited at first argument.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    True
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    >>> not(not(True or False) or (True and False)) # Second argument is evaluated.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    False
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    >>> not(not(False or True) or (False and True)) # Short-circuited at first argument.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    False
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    >>> not(not(False or False) or (False and False)) # Second argument is evaluated.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    True
							 
						 
					
						
							
								
									
										
										
										
											2019-05-20 00:34:23 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```