Guest User

Untitled

a guest
Dec 14th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #Problem 19
  2. #component: a random integer 0-9 representing a problem, 0-7=correct and 8-9=wrong
  3. #trial: generate six random integers
  4. #response: Did we get them all correct?
  5. #statistic: proportion
  6.  
  7. import random
  8. num_trials = 100000
  9. correctproblems = 0
  10. for x in range(num_trials):
  11.  
  12. #trial
  13. correct = True
  14. for n in range (6):
  15.  
  16. problem = random.randint(0,9)
  17. if problem > 7:
  18. correct = False
  19.  
  20. if correct:
  21. correctproblems=correctproblems+1
  22.  
  23. #response
  24.  
  25. print(correctproblems/num_trials)
Add Comment
Please, Sign In to add comment