+ 1
Help pls
Hi everyone, I am trying to make a random number picker. Overall itâs working fine, no bugs or anything but It only works with integers. Can someone tell how can I make this work with floats? https://code.sololearn.com/cy8X2rerpqL1/?ref=app The code is here!
3 Answers
+ 6
import random
import numpy as np
print(random.choice(np.arange(1, 2, .1)))
#You can use this or implement your range function
#(numpy is not builtin)
+ 5
random.choice returns random item from non empty sequence
numpy.arange returns an 'ndarray' (numpy.array) and works like 'range' but parameters can be floats
+ 1
wow thank you so much but can u explain to me what every line means?