Sheep door work

 

1. Answer according to your first feeling. Do you think you have a higher chance of getting a car if you don’t change the choice, or do you think you can get a car with a choice? Or the odds haven't changed?

The odds haven't changed 

2. Please carefully analyze "Is there a higher chance of getting a car if I don't change the choice, or is there a higher chance of getting a car if I change the choice? Or the probability has not changed?" Write down your analysis ideas and results.

Analysis: If you choose not to change, the chance of picking a car is 1/3. If the supporter opens a door with a sheep behind it, the chance of picking a car after changing the choice is 2/3

Result: Switching options has a higher chance of getting a car

3. Please try to write a program to verify your ideas. The verification results support your analysis results, or do not support your analysis results. Please write the program running results and whether they support your analysis. (Hint: This procedure can be done with the help of the random number function)

 

import random
n = random.randint (5000,10000)
change=0
nochange=0
for i in range(1,n+1):
    a = random.randrange (1,4)
    b = random.randrange (1,4)
    if a==b:
        nochange=nochange+1
    else:
        change=change+1
print("The probability of not changing the drawn car is: {}".format(nochange/n))
print("The probability of drawing a car after changing is: {}".format(change/n))

  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325112400&siteId=291194637