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,788 questions

51,694 answers

573 users

How to generate random floating point numbers with SystemRandom class in Python

2 Answers

0 votes
import random


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

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

'''
run:

0.277  0.388
0.294  0.359
0.433  0.784
0.804  0.201
0.057  0.038

'''

 



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

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

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

'''
run:

0.958  0.376
0.077  0.805
0.065  0.810
0.421  0.666
0.195  0.846

'''

 



answered Apr 5, 2016 by avibootz

Related questions

...