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 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

...