NumPy library numpy.random contains several random number generators.

If rand has a number n for an argument it will return an array of n elements. In this example it is an array of five elements.

If no argument is specified a single random number is returned. The random numbers are returned range between 0 and 1.

a, b = 1, 20
(b-a)*rand(5) + a

If you want to generate a random number between a--b. You can do that by stretching the interval that would otherwise go from 0--1 to go for the width of (b-a) by multiplying rand()*(b-a). You can than add a to displace the lower limit .