Python | Numpy ndarray .__ ifloordiv __ ()

With Numpy ndarray .__ ifloordiv __ () we can split a specific value provided as a parameter in ndarray .__ ifloordiv __ () . The value will be split into each element of the array and remember that it always gives the minimum value after division.

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

Return: self // = value

Example # 1:
In this example, we we can see that each element of the array is divided with the value given as a parameter in the ndarray .__ ifloordiv __ () method and gives the minimum value of each element that is split in the array. This method will work well for positive, negative and floating point array values.

# import important module into python

import numpy as np

 
# make an array with NumPy

gfg = np.array ([ 1 , 2.5 , 3 , 4.8 , 5 ])

 
# applying the ndarray method .__ ifloordiv __ () 

print (gfg .__ ifloordiv __ ( 2 ))

Exit:

 [0. 1. 1. 2. 2.] 

Example # 2:

# import important module in python

import numpy as np

 
# make an array with NumPy

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

[ 6 , 5.5 , 4 , 3 , 2.62 ]])

 
# applying the ndarray method .__ ifloordiv __ ()

print (gfg .__ ifloordiv __ ( 3 ))

Exit:

 [[0. 0. 1. 1. 1.] [ 2. 1. 1. 1. 0.]]