Home >Backend Development >Python Tutorial >How to randomly generate 10 integers in Python
To generate random non-repeating integers, you can use sample in random.
Code example:
index = random.sample(range(0,10),10)
The above code means randomly generating 10 non-repeating integers from 1 to 10.
To generate completely random integers, you can use random.randint in numpy.
Code example:
index = np.random.randint(0,10,size=10)
The above code means randomly generating 10 integers from 0 to 10 that may be repeated.
Recommended tutorial: python tutorial
The above is the detailed content of How to randomly generate 10 integers in Python. For more information, please follow other related articles on the PHP Chinese website!