Python | Numpy ndarray .__ ixor __ ()

NumPy | Python Methods and Functions

With the Numpy ndarray .__ ixor __ () method, we can get XOR elements by value, which is provided as a parameter in numpy.ndarray .__ ixor __ () .

Syntax: ndarray .__ ixor __ ($ self, value, /)

Return: self ^ = value

Example # 1:
In this example, we see that each element has an xor value by the value that is passed as parameter in ndarray .__ ixor __ () .

# import important module into python

import numpy as np

 
# make an array with NumPy

gfg = np.array ([ 1 , 2 , 3 , 4 , 5 ])

 
# applying the ndarray method .__ ixor __ ()

print (gfg .__ ixor __ ( 2 ))

Exit:

 [3 0 1 6 7]  

Example # 2:

Exit:

 [[0 3 2 5 4] [7 4 5 2 3]] 




Get Solution for free from DataCamp guru

# import important module into python

import numpy as np

 
# make an array with NumPy

gfg = np.array ([[ 1 , 2 , 3 , 4 , 5 ],

[ 6 , 5 , 4 , 3 , 2 ]])

 
# applying the ndarray method .__ ixor __ ()

print (gfg .__ ixor__ ( 1 ))