from random import random x = 10 y = [] avg = 0 for i in range(x): y.append(random()) print("%5.2f" % y[i], end='') avg += y[i] print() average = avg/x print("Find average of array and find highest numbers than the average") print("The average of the array = %.2f" % average) print("Numbers greater than the average number are below: ") for i in y: if i > average: print("%4.2f" % i) |
Output:
0.82 0.50 0.94 0.74 0.80 0.63 0.27 0.83 0.42 0.79
0.83 0.04 0.44 0.17 0.65 0.67 0.51 0.00 0.21 0.51
|