NumPy Random Shuffle and Permutations

Machine Learning courses with 100+ Real-time projects Start Now!!

Program 1

# Random Shuffle and Permutations in NumPy
#shuffle() and permutation().
import numpy as np
from numpy import random
# mylist=['12@56','Yu562',345,'Thg78$',67.677]
# mylist=random.permutation(mylist)
# print(mylist[0])

myar=np.array([0,1,1,0])
random.shuffle(myar)
#print(myar[0])
if(myar[0]==0):
    print("HEAD")
else:
    print("TAIL")   










# myar=np.array([1,2,3,4,5,6,7,8,9,10])
# print(myar)
# newar=random.permutation(myar)
# print(newar)

# mylist=['12@56','Yu562',345,'Thg78$',67.677]
# random.shuffle(mylist)
# print(mylist[0])

# myar=np.array([3431,2212,3654,7984,1455,7676,3457,7688,1249,7670])
# print(myar)
# random.shuffle(myar)
# print(myar[0])












# mylist=[10,4,6,"Hello",45.66,True,"Indore",23.44,False]
# print(mylist)
#random.shuffle(mylist)
# mylist1=random.permutation(mylist)
# print(mylist1)


# myar=np.array([1,2,3,4,5,6,7,8,9,10])
# newar=random.permutation(myar)
# print(myar)
# print(newar)

#myar=np.array([7892,4562,2323,2124,1578,3667,8657,3490,2319,2360])
# random.shuffle(myar)
# # newar=random.choice(myar,size=(2,3,3))
# print(newar)
# # print(myar[0])

# mylist=[0,1,0,1,1]
# random.shuffle(mylist)
# print(mylist[0])
# if(mylist[0]==0):
#     print("Head")
# else:
#     print("Tail")

 

Did we exceed your expectations?
If Yes, share your valuable feedback on Google

courses
Image

DataFlair Team

DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.

Leave a Reply

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