Home > other >  Python dice game
Python dice game

Time:10-20

A plate of the game, two people take turns to roll the dice, 5 times and each time a vote of points accumulation, after five innings, won with strong accumulated points, points for the same draw, according to the rules to realize the dice game, and calculate the 50 plate after victor (win the maximum number of plate of 50 set, that is the final winner)
Using the random module extension: the randint () method then throw some function (randint (1, 6))

CodePudding user response:

Import the random

A_win=0
B_win=0

For I in range (50) :
A, b=0, 0
For I in range (5) :
A +=random. Randint (1, 6)
B +=random. Randint (1, 6)
If a> B: a_win +=1
If aIf a_win==b_win:
Print (" draw ")
The else:
Print (" a "if a> B the else "b")
  • Related