mercredi 30 octobre 2019

How to make a1,a2, and a3 to be read in the looping?

I have a problem where I need to randomize the value in the array, but I need to declare a1, a2 and a3 outside because a1, a2 and a3 need to be equal to 100. But when I do that, there cannot be randomize.. the looping keep execute the same value of random.

a3=rd.randint(0,1)
a2=rd.randint(0,50)
a1=100-a2-a3
random_array =  np.array([np.array([rd.randint(0,1), rd.randint(0,2), a2, a1, a3]) for _ in range(x)])

Here the result that I got:

[ 0  2  6 94  0]   
[ 1  0  6 94  0]  
[ 1  1  6 94  0]   
[ 0  2  6 94  0] 
[ 1  0  6 94  0]   
[ 1  2  6 94  0]  
[ 0  2  6 94  0]  
[ 1  0  6 94  0]   
[ 1  1  6 94  0]   



Aucun commentaire:

Enregistrer un commentaire