Python | Numpy ndarray .__ ior __ ()

NumPy | Python Methods and Functions

With the Numpy ndarray .__ ior __ () method we can get OR elements by the value provided as a parameter in numpy.ndarray .__ ior __ () .

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

Return: self | = value

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

# 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 .__ ior __ ()

print ( gfg .__ ior __ ( 2 ))

Exit:

 [3 2 3 6 7] 

Example # 2:

# import important module in python

import numpy as np

 
# make array with NumPy

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

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

 
# applying the ndarray method .__ ior __ ()

print (gfg .__ ior __ ( 1 ))

Output:

 [[1 3 3 5 5] [7 5 5 3 3]] 




Get Solution for free from DataCamp guru