Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Problem 19
- #component: a random integer 0-9 representing a problem, 0-7=correct and 8-9=wrong
- #trial: generate six random integers
- #response: Did we get them all correct?
- #statistic: proportion
- import random
- num_trials = 100000
- correctproblems = 0
- for x in range(num_trials):
- #trial
- correct = True
- for n in range (6):
- problem = random.randint(0,9)
- if problem > 7:
- correct = False
- if correct:
- correctproblems=correctproblems+1
- #response
- print(correctproblems/num_trials)
Add Comment
Please, Sign In to add comment