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)