{}
BLACK NOVEMBER
Get 66% off PRO
Are you struggling to build your coding confidence or land your first job?
Fast-track to your first pay-check.
Start PRO
Start PRO
BLACK NOVEMBER
Get 66% off PRO
Are you struggling to build your coding confidence or land your first job?
Fast-track to your first pay-check.
Start PRO
Start PRO
run-icon
main.py
# Online Python compiler (interpreter) to run Python online. # Write Python 3 code in this online editor and run it. import numpy as np doors = ["goat","goat","car"] #1st choice will be door you choose, 2nd choice will be door that is revealed. #This code simulates your selection of a door, and the door that is randomly revealed. print("test:",np.random.choice(doors,2,replace=False)) num_cars_won_if_switched = 0 num_goats_revealed = 0 for i in range(10000): trial = np.random.choice(doors,2,replace=False) if trial[1] == "goat": #door revealed was a goat num_goats_revealed += 1 if trial[0] == "goat": num_cars_won_if_switched += 1 print(num_cars_won_if_switched/num_goats_revealed)
Output