-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMonte Hall.py
More file actions
43 lines (40 loc) · 1.01 KB
/
Monte Hall.py
File metadata and controls
43 lines (40 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 6 13:47:03 2021
@author: SINCHAN BASU
"""
import random
doors=[0]*3
goatdoor=[0]*2
swap=0 #No of swap wins
dont_swap=0 #No of dont swap wins
j=0
while(j<10):
x=random.randint(0,2) #x th door will comprise of BMW
doors[x]="BMW"
for i in range(0,3):
if(i==x):
continue
else:
doors[i]="Goat"
goatdoor.append(i)
choice=int(input("Enter your choice"))
door_open=random.choice(goatdoor) #open a door that comprises of goat
while (door_open==choice): #door open shouldn't be equal to choice made by the participant
door_open=random.choice()
ch= input("Do you want to swap? y/n")
if (ch=='y'):
if (doors[choice]=='Goat'):
print("Player wins")
swap=swap+1
else:
print("Player lost")
else:
if(doors[choice]=='Goat'):
print("Player lost")
else:
print("Player wins")
dont_swap=dont_swap+1
0j=j+1
print(swap)
print(dont_swap)