+ 1
if someone can explain this problem
Declare a variable X that stores a list of 100 integers randomly sampled between -25 and 25. I know how to create an empty and to append to that list but I don t know how I generate that numbers to be in total 100 , if we know that lenght of that renge is just 50
4 Answers
+ 2
You can use the built-in random library also.
random.choices(range(-25,26), k=100)
https://code.sololearn.com/ckK4JLBVwSYK/?ref=app
0
#For example using numpy:
import numpy as np
print(np.random.randint(-25, 25+1, 100))
0
and can be do without Numpy or Scipy?
0
You would need to write your own algorithm to generate (pseudo)random numbers if you don't want to use libraries
(edited)