How to generate random float multiple times in Python

2 Answers

0 votes
import random
import time

seed = time.time()
    
rn1 = random.Random(seed)     
rn2 = random.Random(seed)

for i in range(7):          
      print('{:04.3f} {:04.3f}'.format(rn1.random(), rn2.random()))




'''
run:

0.631 0.631
0.538 0.538
0.125 0.125
0.815 0.815
0.924 0.924
0.949 0.949
0.066 0.066

'''

 



answered Jun 14, 2019 by avibootz
0 votes
import random

rn1 = random.Random()     
rn2 = random.Random()

for i in range(7):          
      print('{:04.3f} {:04.3f}'.format(rn1.random(), rn2.random()))




'''
run:

0.925 0.049
0.915 0.432
0.663 0.662
0.856 0.163
0.557 0.747
0.111 0.940
0.370 0.917

'''

 



answered Jun 14, 2019 by avibootz

Related questions

...