Home > other >  Python for answers
Python for answers

Time:12-03

Generate 10 [0, 1] random floating point, within the scope of descending order after a floating point number in each row (keep 4 decimal places) written text file data. TXT

CodePudding user response:

Import the random

With the open (' data. TXT ', 'w') as f:
For I in range (10) :
F.w rite (' %. 4 f \ n % random. The random ())

CodePudding user response:

Import the random

With the open (' data. TXT ', 'w') as f:
L=[]
For I in range (10) :
L.A. ppend (random. The random ())
L.s ort (reverse=True)
For I in l:
F.w rite (' %. 4 f \ n % I)

Just forgot to sort

CodePudding user response:

refer to the second floor zzzzzyyy12 response:
import random

With the open (' data. TXT ', 'w') as f:
L=[]
For I in range (10) :
L.A. ppend (random. The random ())
L.s ort (reverse=True)
For I in l:
F.w rite (' %. 4 f \ n % I)

Just forget to sort the

Thank you very much! Thank you very much!
  • Related