學生習題一,隨機模塊已經循環結構的練習

#重複產生若干個位於0道100之間的整數,直到他們的和大於大於10000,求平均值與和
# 隨機過程必然導入random模塊
import random
num_list=[]
all=0
while all<10000:
   new=random.randint(0,100)
   num_list.append(new)
   all+=new
print(all,all/len(num_list))
    

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章