  # Python | Numpy numpy.ndarray .__ xor __ ()

NumPy | Python Methods and Functions

With the ` Numpy numpy.ndarray .__ xor __ () ` method we can get XOR elements by the value that is provided as a parameter in ` numpy.ndarray .__ xor __ () `.

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

Return: self ^ value

Example # 1:
In this example, we see that each element has a value xor by value that is passed as a parameter to ` ndarray .__ xor __ () `.

` `

` # import important module in python import numpy as np   # make an array with NumPy gfg = np.array ([ 1 , 2 , 3 , 4 , 5 ])   # applying the ndarray .__ xor __ () method print (gfg .__ xor __ ( 2 )) `

` ` Exit:

` [3 0 1 6 7] `

Example # 2:

` `

 ` # import important module in 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 .__ xor __ () ` ` print ` (gfg .__ xor __ ( ` 1 ` `)) `
` `

` ` Exit:

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