Categories
Blog Data Science Python

Python random numbers

When I experiment in Python I often need a list of random integers. When I was looking for code to generate that I couldn’t believe how complicated people are doing that and present it after in their blog. Anyway here are two very easy ways to generate random lists.

import random
[random.randint(1,100) for i in range(10)]
#
import numpy as np
np.random.randint(1,100,10)