0
How to generate random number between 10 & 1000??
How to generate random number??
3 Antworten
+ 1
import random
x=random.randint(10, 1000)
randrange will only return up to 999, like the native range function.
+ 1
In javascript :
Math.floor(Math.random()*990) + 10;
Here,
1. Math.random() will generate a number between 0 to 1.
2. Multiplying the number by 990 times will be a number between 0 to 990.
3. Adding 10 with the number will make it between 10 to 1000.
4. Math.floor() will make the lowest round number instead of any decimal number.
Hope this will work.
0
slight mistake!
multiply it by 990, not 1000. that would result in 10 to 1010.