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

51,876 answers

573 users

How to create a list with random float numbers in Python

2 Answers

0 votes
from random import random

lst = []

for i in range(10):
  lst.append(random())


print(lst)




'''
run:

[0.9889866453247984, 0.8771845972814758, 0.5908496615752831, 0.8849110158919037,
 0.19743691128186902, 0.0037100871582196326, 0.8937119725397518, 0.07711042399095525, 
 0.7383634205961315,0.1401251089804877]

'''

 



answered Aug 21, 2019 by avibootz
0 votes
from random import random

lst = [random() for _ in range(10)]


print(lst)




'''
run:

[0.3877398792618426, 0.7741406241058341, 0.8664703924691155, 0.7246124509264523,
 0.37322484147028334, 0.7076929078344093, 0.013553454699449463, 0.6503610823786135,
 0.5450804738554014, 0.7999369742900859]

'''

 



answered Aug 21, 2019 by avibootz

Related questions

1 answer 129 views
2 answers 237 views
1 answer 155 views
1 answer 157 views
1 answer 95 views
1 answer 141 views
...