Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- def rollDie(number): # cleaner version
- results = []
- for i in range(0, 50):
- place = random.randint(1, 6)
- print(place)
- results.append(place)
- return results
- def most_common(lst):
- def function(a):
- return a[1]
- return max(((item, lst.count(item)) for item in set(lst)), key=function)[0]
- results = rollDie(50) # 50 rolls
- total = 0 # creating total
- for i in results:
- total += i # adding up all the dice rolls
- print("Total: ", total / 50) # Average from the 50 dice rolled
- print("Most Frequent Number: ", most_common(results)) # most occuring number
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement