当前位置: 移动技术网 > IT编程>脚本编程>Python > 羊车门

羊车门

2019年04月25日  | 移动技术网IT编程  | 我要评论

葬神空间,又名常宁站长网,甄姬乱舞

作业完成人:

学号:20181004011,刘飞宇

学号:20181004023,赵盛阳

1:换选择几率高

2:①不换选择几率为1/3  ②换选择:若选中汽车,则换选择后肯定错误;若选中羊,则换选择后必定正确,因为有两只羊,所以正确率为2/3;

3

 1 import random
 2 max=100000
 3 change=0
 4 no_change=0
 5 for i in range(max):
 6         x = random.randint(0,2)
 7         y = random.randint(0,2)
 8         if x==y:
 9                 no_change+=1
10         else:
11                 change+=1
12 print("change:{}".format(change/max))
13 print("no change:{}".format(no_change/max))  
结果正如猜想。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网