
- 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
What are different bitwise operators types in Python?
Bitwise operators operate upon bits as operands. Following bitwise operators are defined in Python −
- & (bitwise AND): returns 1 if both bit operands are 1
- | (bitwise OR): returns 1 even if one of two bit operands is 1
- ^ (bitwise XOR): returns 1 only if one operand is 1 and other is 0
- ~ (bitwise complement): returns 1 if operand is 0 and vice versa
- << (bitwise left-shift): bits are shifted to left and right most bits are set to 0
- >> (bitwise right-shift): bit are shifted to right and left most bits are set to 0
For example a = 60 (0011 1100 binary) and b = 13 (0000 1101 binary)
a&b = 0000 1100 = 12 a|b = 0011 1101 = 61 a^b = 0011 0001 = 49 ~a = 1100 0011 = -61 a<<2 = 1111 0000 = 240 a>>2 = 0000 1111 = 15
- Related Articles
- What are different Identity operators types in Python?
- What are different assignment operators types in Python?
- What are bitwise operators in C#?
- What are JavaScript Bitwise Operators?
- Python Bitwise Operators
- What are different basic operators in Python?
- What are different arithmetic operators in Python?
- What are the bitwise operators in Java?
- Different types of operators in C++
- What are different types of quotes in Python?
- Bitwise Operators in C
- Bitwise Operators in C++
- Java Bitwise Operators
- Perl Bitwise Operators
- What types of logical operators are in javascript?

Advertisements