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)