Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- import random
- rolls=2
- num=1000000
- low = 740
- high = 5180
- def rollingDie():
- total = 0
- for i in range(num):
- trials = []
- for j in range(rolls):
- trials.append(random.randint(low, high)) # adds a trial to the array
- trials.sort(reverse=True) # sorts from greatest to least
- total+=trials[0]/num # adds on the greatest roll. /num for averaging
- return total
- def avgDist():
- tot=0
- for i in range(num):
- tot+=abs(random.randint(low, high)- random.randint(low, high))/num
- return tot
- print(rollingDie())
Advertisement
Add Comment
Please, Sign In to add comment