samedi 7 mars 2020

How do I create a two column and 21 row file using random values in Python?

Here are my instructions:

Generate a 2-column and 21-row file with random values using file operation and the random method.

Example:

Name0 0.9384995
Name1 0.8299104
Name3 0.3848841
...etc until Name20 

read the file and output the two columns in ascending order of the random values identify the min, max, median, and average of these values.

So far I have

import random
mylist= []
for i in range (0,20):
    x=random.random()
    mylist.append(x)

I am stuck here and do not know how to add the Name0, Name1, Name2... (etc) to correspond to the random values in a column format.




Aucun commentaire:

Enregistrer un commentaire