Randamize the numpy array elements using python

to randomize the numpy array elements using python

we can randomize the elements of a Numpy array in python using the ‘numpy.randam.shuffle’ function.

for that firstly we have to import numpy libraries

import numpy as np

the we have to create a numpy array by using

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

now we can randomize the  array elements  using the np.randam.shuffle function

np.random.shuffle(array)

then we have to print the array

print(array)

this will shuffle the numpy array elements by using python.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top