Home > other >  Python beginners, there are a great god can help have a look
Python beginners, there are a great god can help have a look

Time:09-18

Generate 10 random floating point between living [10], as the result of the experiment, (1) calculate the average, (2) for all points and the average of the average point distance, the distance can measure the distribution of the experimental results,

CodePudding user response:

 import random 

Ls=list ()
Ls2=list ()
For I in range (10) :
Ls. Append (random uniform (10, 90)) # to save 10 floats to the ls
Print (ls)
Avg=sum (ls)/len (ls)
Print (avg)
For the item in the ls:
Ls2. Append (item - avg) # every experimental results to the average distance
Print (ls2)
Avg2=sum (ls2)/len (ls2) # all points and the average distance of average
Print (avg2)

CodePudding user response:

reference 1st floor goofs off explode reply:
 import random 

Ls=list ()
Ls2=list ()
For I in range (10) :
Ls. Append (random uniform (10, 90)) # to save 10 floats to the ls
Print (ls)
Avg=sum (ls)/len (ls)
Print (avg)
For the item in the ls:
Ls2. Append (item - avg) # every experimental results to the average distance
Print (ls2)
Avg2=sum (ls2)/len (ls2) # all points and the average distance of average
Print (avg2)

Thanks to the great god, the program class specialty, writing Python is too difficult

CodePudding user response:

The bad: I understand: "for all the points and the average distance" : yes this sentence mean, the number average is the average of 10 points, distance is the number 10 average reduction, hope this will not affect your academic research,
  • Related