How to generate random integers in a specific range in Python

2 Answers

0 votes
import random


for i in range(10):
    print(random.randint(1, 100))


'''
run:

10
90
98
91
38
62
69
88
80
10

'''

 



answered Apr 6, 2016 by avibootz
0 votes
import random


for i in range(10):
    print(random.randint(-10, 10))


'''
run:

-4
-8
3
-1
8
6
7
8
2
4

'''

 



answered Apr 6, 2016 by avibootz

Related questions

5 answers 245 views
3 answers 238 views
1 answer 139 views
1 answer 133 views
...