羊车门问题

from random import*
x=eval(input("请输入模拟次数:"))
car = 0
car1 = 0
for i in range (1,x+1):
    a = randrange(1,5)
    b = randrange(1,5)
    if a==b:
        car1 = car1+1
    else :
        car = car+1
print("更改后选中汽车的概率为",car/x)
print("不改选中汽车的概率为",car1/x)


你可能感兴趣的:(学习)