Advertisement
Buffet_Time

Untitled

Apr 8th, 2016
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. import random
  2.  
  3.  
  4. def rollDie(number): # cleaner version
  5. results = []
  6. for i in range(0, 50):
  7. place = random.randint(1, 6)
  8. print(place)
  9. results.append(place)
  10. return results
  11.  
  12.  
  13. def most_common(lst):
  14. def function(a):
  15. return a[1]
  16.  
  17. return max(((item, lst.count(item)) for item in set(lst)), key=function)[0]
  18.  
  19.  
  20. results = rollDie(50) # 50 rolls
  21. total = 0 # creating total
  22. for i in results:
  23. total += i # adding up all the dice rolls
  24. print("Total: ", total / 50) # Average from the 50 dice rolled
  25. print("Most Frequent Number: ", most_common(results)) # most occuring number
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement