place a number randomly in a list python 1

place a number randomly in a list python

offsetBiasSample = [randint(-10,10)/100 for i in range(10)]
offsetBias = choice(offsetBiasSample)
index_offsetBias = randint(0,len(oldBiases)-1)
oldBiases[index_offsetBias] = oldBiases[index_offsetBias] + offsetBias 

Here is what the above code is Doing:
1. It’s creating a list of 10 random numbers between -10 and 10.
2. It’s choosing one of those numbers at random.
3. It’s choosing one of the old biases at random.
4. It’s adding the random number to the random bias.

Similar Posts