[go: up one dir, main page]

0% found this document useful (0 votes)
17 views1 page

Bitwise XOR Operator

The Bitwise XOR Operator (^) performs a logical exclusive OR operation on two binary values, producing a result based on a truth table. Examples demonstrate its usage with integers, revealing how it operates on binary representations, while also highlighting type errors with unsupported data types. The operator yields a result of 1 when the inputs differ and 0 when they are the same.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views1 page

Bitwise XOR Operator

The Bitwise XOR Operator (^) performs a logical exclusive OR operation on two binary values, producing a result based on a truth table. Examples demonstrate its usage with integers, revealing how it operates on binary representations, while also highlighting type errors with unsupported data types. The operator yields a result of 1 when the inputs differ and 0 when they are the same.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

=======================================================

Bitwise XOR Operator ( ^ )


=======================================================
=>Syntax: Value1 ^ Value2
=>The Functionality of Bitwise XOR Operator ( ^ ) is shown in the following Truth
Table

-----------------------------------------------------------
----------------
Value1 Value2 Value1 ^ Value2
-----------------------------------------------------------
----------------
1 0 1
0 1 1
0 0 0
1 1 0
-----------------------------------------------------------
----------------
-------------------------
Example-1
-------------------------
>>> 1^0
1
>>> 0^1
1
>>> 0^0
0
>>> 1^1
0
--------------------------
Example-2
--------------------------
>>> a=2-----------------------0010
>>> b=3-----------------------0011
-------------------
>>> c=a^b 0001----which is the result of 1
>>> print(c)---------1
>>> print(10^15)------5
>>> print(345^345)----0
--------------------------
Examples-3
--------------------------
>>> {1.2,3.4,4.5}^{4.5,1.2,3.4}-----------------set()
>>> "RADAR" ^ "ABRAKADABRA"-------------TypeError: unsupported operand type(s) for
^: 'str' and 'str'
>>> set("RADAR") ^ set("ABRAKADABRA")---------{'B', 'K'}
>>> 1.2^2.3----------------------------------------------------TypeError:
unsupported operand type(s) for ^: 'float' and 'float'
==========================================x========================================
======

You might also like