Forum Discussion
baxatob
Community Hero
import random random.randint(min_, max_) #will return random integer between min_ and max_
In Python you should use a module random to operate random values.
Colin_McCrae
8 years agoCommunity Hero
Just to add to baxatob's reply re. Python random numbers ....
randint (his example) is inclusive. So will return a random integer from 0-9 (including 0 and 9). So, technically, "between" isn't quite accurate.
Also, you probably want to seed it. (Which is what the "randomize" statement in the VB version does.)
In Python, use "random.seed()" (in this form - with no value passed in - it will use current time as the seed) to avoid getting the same sequence of (pseudo) random numbers every time. See here: http://stackoverflow.com/questions/22639587/random-seed-what-does-it-do - if you want an explanation.
Related Content
Recent Discussions
- 3 days ago
- 3 days ago
- 6 days ago