''' random random module ''' import random # A random number from 1-6 print(random.randint(1,6)) ''' Dice 6000 counts the number of occurrences of 1-6 ''' num = random.randrange(1,100,2) #Random 2 numbers in 1-100 random.sample([1,2,3,4,5,6,7],2) #Random 2 numbers in the specified range count = 0 nums = [0,0,0,0,0,0] while count<6000: count += 1 num = random.randint (1,6) nums[num-1] += 1 for i in range(1,7): print("{0}有{1}个".format(i,nums[i-1]))
random module for python notes
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=324910109&siteId=291194637
Ranking