I would like to make random numbers in a specific range, like \"pick a random number between 18 and 35\"? How can I do that with the rand() function?
in general, if rand() returns a float value in [0.0 ... 1.0) (that is, you may get values arbitrarily close to 1.0 but not actually 1) then you will want something like
hi = 36
lo = 18
res = int( (hi-lo)*rand() + lo ) # returns random values in 18..35
Note that this will never actually return the hi value - therefore I have incremented it by 1 (ie, you will get all values from 18 to 35 inclusive, but never 36).
Hope that helps.