
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Python Boolean Operations
The basic Boolean operations are and, or, not operations.
The and operation − The basic syntax of and operation is: x and y. It indicates that when the x is false, then return x, otherwise returns y.
The or operation −The basic syntax of or operation is: x or y. It indicates that when the x is false, then return y, otherwise returns x.
The not operation − The basic syntax of and operation is: not x. It indicates that when the x is false, then it returns true, otherwise it returns false.
Example Code
x = 25 y = 18 or_op = x or y print(or_op) and_op = x and y print(and_op) not_op = not x print(not_op) x = 0 not_op = not x print(not_op)
Output
25 18 False True
- Related Articles
- Boolean Indexing in Python
- Boolean Values in Python
- Python - Contiguous Boolean Range
- Boolean list initialization in Python
- What are boolean operators in Python?
- Parsing A Boolean Expression in Python
- String Operations in Python\n
- Common string operations in Python
- Basic List Operations in Python
- Basic Tuples Operations in Python
- Python – Extract Row with any Boolean True
- Write a Pyton program to perform Boolean logical AND, OR, Ex-OR operations for a given series
- Python Shallow and Deep Copy operations
- Arithmetic operations using OpenCV in Python
- High-level file operations in Python (shutil)

Advertisements