Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,885 questions

51,811 answers

573 users

How to multiple simultaneous generate random numbers in Python

3 Answers

0 votes
import random

r1 = random.Random()
r2 = random.Random()

for i in range(10):
    print('%04.3f  %04.3f' % (r1.random(), r2.random()))


'''
run:

0.823  0.752
0.602  0.275
0.899  0.777
0.939  0.910
0.570  0.925
0.907  0.573
0.055  0.646
0.897  0.798
0.312  0.277
0.969  0.646

'''

 



answered Apr 6, 2016 by avibootz
0 votes
import random
import time

seed = time.time()
r1 = random.Random(seed)
r2 = random.Random(seed)

''' same numbers '''
for i in range(10):
    print('%04.3f  %04.3f' % (r1.random(), r2.random()))


'''
run:

0.946  0.946
0.462  0.462
0.580  0.580
0.247  0.247
0.805  0.805
0.371  0.371
0.935  0.935
0.766  0.766
0.424  0.424
0.090  0.090

'''

 



answered Apr 6, 2016 by avibootz
0 votes
import random
import time

seed = time.time()
r1 = random.SystemRandom(seed)
r2 = random.SystemRandom(seed)

''' different numbers '''
for i in range(10):
    print('%04.3f  %04.3f' % (r1.random(), r2.random()))


'''
run:

0.230  0.241
0.581  0.854
0.890  0.481
0.362  0.796
0.311  0.165
0.707  0.574
0.012  0.044
0.237  0.068
0.701  0.115
0.728  0.561

'''

 



answered Apr 6, 2016 by avibootz
...