Python | Numpy numpy.ndarray .__ rshift __ ()

NumPy | Python Methods and Functions

Using the numpy.ndarray.__rshift__() method, we can get elements that are shifted to the right by the value specified as a parameter in numpy.ndarray .__ rshift __ () .

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

Return: self & gt; & gt; value

Example # 1:
In this example, we see that each the element is shifted to the right by the value passed as a parameter to ndarray .__ rshift __ () .

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

print (gfg .__ rshift __ ( 2 ))

Exit:

 [0 0 0 1 1] 

Example # 2:

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

print (gfg .__ rshift __ ( 1 ))

Exit:

 [[0 1 1 2 2] [3 2 2 1 1 ]] 




Get Solution for free from DataCamp guru