

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 Questions & Answers
- What are different Identity operators types in Python?
- What are different assignment operators types in Python?
- What are JavaScript Bitwise Operators?
- What are bitwise operators in C#?
- What are different basic operators in Python?
- What are different arithmetic operators in Python?
- Python Bitwise Operators
- What are the bitwise operators in Java?
- Different types of operators in C++
- What are different types of quotes in Python?
- What types of logical operators are in javascript?
- Java Bitwise Operators
- Perl Bitwise Operators
- What are different Perl Data Types?
- What are different types of interrupts?
Advertisements