#小游戏, shake a sieve bet the size of the game import random# defines the function of the Shake sieve: def roll_dice (number = 3,points = None): Print (' <<<<< roll the Di Ce >>>>> ') if points is none:points = [] while number > 0:point = Random.randrange (1,7) Points.append (point) Number = Number-1 return points# Convert the number of points to a function of size: def roll_result (total): IsBig = <= Total < Issmall = 3 <= Total < if Isbig:return ' IsBig ' elif issmall:re Turn ' issmall ' #开始游戏的函数;d EF start_game (): Print (' <<<<< game start >>>>> ') choices = [' IsBig ', ' issmall '] your_choices = input (' IsBig or Issmall: ') if your_choices in choices:points = Roll_dice () Total = SUM (points) Youwin = Your_choices = = Roll_result (total) if Youwin:print (' The Poin TS is ', points, ' you win! ') Else:print (' The points is ', points, ' you lose! ') Else:print (' Invalid Words ') start_gaMe ()
Python roll dice guess the size of the small game