Sheep door work (pair work)

0. This topic is a pairing assignment. First, write the student numbers and names of the two students in the following form (it is assumed here that the homework is completed by two students whose student numbers are 20184010001 Li Li and 20184540035 Wang Dong, and the two students only need to One of the students can submit this assignment):

作业完成人:
学号:20171301005,许世长
学号:20171301029,陈成

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?

Answer: The odds have not 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.

Answer: The odds have not changed, because there is only one car in the 3 doors, no matter how you choose it is one third

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)

A: No support for my idea

operation result

Do not change 0.3370620167790755
Change the door 0.6629379832209245

4. Please attach your code. (Hint: Use the Insert Code feature in the editor to display the code in Python style)

code show as below:

import random
x = random.randint (5000,10000)
change=0
nochange=0
for i in range(1,x+1):
    a = random.randint (1,3)
    b = random.randint (1,3)
    if a==b:
        nochange=nochange+1
    else:
        change=change+1
print(nochange/x)
print(change/x)

  

Guess you like

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