Python: Generate random number between x and y which is a multiple of 5 [duplicate]
Create an integer random between e.g. 1-11
and multiply it by 5
. Simple math.
import random
for x in range(20):
print random.randint(1,11)*5,
print
produces e.g.
5 40 50 55 5 15 40 45 15 20 25 40 15 50 25 40 20 15 50 10
>>> import random
>>> random.randrange(5,60,5)
should work in any Python >= 2.