import random #use a list to manage our 5 dice: five_dice = [] #roll 5 dice, one at a time: for roll in range(5): #each roll is between 1 and 6: dice_roll = random.randint(1,6) #join the roll to the list of dice: five_dice.append(dice_roll) #show the list of five dice: print(five_dice)
[3, 6, 3, 1, 4]
Combination | Example | Importance |
---|---|---|
No Pair | [2, 6, 4, 1, 3] |
1 |
One Pair | [2, 6, 2, 1, 3] |
2 |
Two Pair | [4, 1, 4, 5, 5] |
3 |
Three of a Kind | [4, 1, 4, 4, 6] |
4 |
Four of a Kind | [2, 2, 2, 3, 2] |
5 |
Full House | [5, 5, 2, 5, 2] |
6 |
Bottom Straight | [4, 3, 2, 5, 1] |
7 |
Top Straight | [5, 6, 3, 4, 2] |
8 |
Yahtzee | [4, 4, 4, 4, 4] |
9 |
[2, 1, 4, 6, 5] No Pair
[6, 6, 2, 3, 6] Three of a Kind
n
number of rolls, where n
is an integer inputted by the user, and tally the results as follows:Number of rolls: 5 [4, 5, 1, 2, 2] [2, 6, 6, 6, 3] [5, 1, 5, 1, 3] [3, 2, 3, 6, 6] [4, 2, 1, 5, 3] No Pair: 0 One Pair: 1 Two Pair: 2 Three of a Kind: 1 Four of a Kind: 0 Full House: 0 Bottom Straight: 1 Top Straight: 0 Yahtzee: 0