0

How to generate random number between 10 & 1000??

How to generate random number??

19th Feb 2021, 5:27 PM
Shairryal Ali
Shairryal Ali - avatar
3 ответов
+ 1
import random x=random.randint(10, 1000) randrange will only return up to 999, like the native range function.
19th Feb 2021, 5:38 PM
Wilbur Jaywright
Wilbur Jaywright - avatar
+ 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.
19th Feb 2021, 5:54 PM
Imtiaz Faisal
Imtiaz Faisal - avatar
0
slight mistake! multiply it by 990, not 1000. that would result in 10 to 1010.
19th Feb 2021, 6:21 PM
Wilbur Jaywright
Wilbur Jaywright - avatar