实验:硬币向上的次数

import random
heads = 0
for i in range(1, 1001):
    if random.randint(0, 1) == 1:
        heads = heads + 1
    if i == 500:
        print('Halfway done!')
print('Heads came up ' + str(heads) + ' times.')

 

posted @ 2019-03-13 16:15  晨光曦微  阅读(129)  评论(0编辑  收藏  举报