Advertisement
rickzman

Untitled

Dec 8th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. # dice
  2.  
  3. from random import randint
  4.  
  5. def roll():
  6. dice_roll1 = randint(2,6)
  7. dice_roll2 = randint(2,6)
  8. dice_roll = dice_roll1 + dice_roll2
  9. return dice_roll
  10.  
  11. def times(dice_roll):
  12. rolls [dice_roll] += 1
  13. return dice_roll
  14.  
  15. rolls=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
  16. n = 0
  17. while n < 20:
  18. dice_roll = times(roll())
  19. n += 1
  20.  
  21. print("With 20 rolls")
  22. print("2 came up", rolls[2], "times")
  23. print("3 came up", rolls[3], "times")
  24. print("4 came up", rolls[4], "times")
  25. print("5 came up", rolls[5], "times")
  26. print("6 came up", rolls[6], "times")
  27. print("7 came up", rolls[7], "times")
  28. print("8 came up", rolls[8], "times")
  29. print("9 came up", rolls[9], "times")
  30. print("10 came up", rolls[10], "times")
  31. print("11 came up", rolls[11], "times")
  32. print("12 came up", rolls[12], "times")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement