码迷,mamicode.com
首页 > 其他好文 > 详细

实验:硬币向上的次数

时间:2019-03-13 16:26:56      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:实验   div   range   import   hal   col   one   and   bsp   

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.)

 

实验:硬币向上的次数

标签:实验   div   range   import   hal   col   one   and   bsp   

原文地址:https://www.cnblogs.com/chenxi188/p/10523913.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!