代码如下:
1 import random
2
3 n = 0
4 sum = 0
5 while n < 10:
6 num = random.randint(1, 100)
7 sum = sum + num
8 n += 1
9 print(num, end=",")
10 print()
11 print("10个数的和为:%d" % sum)
12 print("10个数的平均值为:%.2f" % (sum / 10))
运行结果: