
- 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
How to bitwise XOR of hex numbers in Python?
You can get the XOR of any type of numbers using the ^ operator. Specifically for hex numbers, you can use:
a = 0x12ef b = 0xabcd print(hex(a ^ b))
This will give the output:
0xb922
The 0x at the beginning of the numbers implies that the number is in hex representation. You can use the ^ operator for other integer representations as well.
- Related Articles
- How to perform bitwise XOR operation on images in OpenCV Python?
- Bitwise XOR in Arduino
- Program to find XOR sum of all pairs bitwise AND in Python
- What is Bitwise XOR in C++?
- How to Convert Hex Numbers to Decimal Numbers in Excel?
- What is Bitwise XOR Operator (^) in JavaScript?
- What is JavaScript Bitwise XOR (^) Operator?
- What is Bitwise XOR Assignment Operator (^=) in JavaScript?
- How to perform Bitwise XOR operation on two images using Java OpenCV?
- Program to find bitwise AND of range of numbers in given range in Python
- Python program to print decimal octal hex and binary of first n numbers
- Count pairs with Bitwise XOR as EVEN number in C++
- Count pairs with Bitwise XOR as ODD number in C++
- Working with hex numbers in MySQL?
- Bitwise AND of Numbers Range in C++

Advertisements