Python 3.0+ Black Jace Dice Game with Help commands The rules are fairly simple,
ID: 667981 • Letter: P
Question
Python 3.0+ Black Jace Dice Game with Help commands
The rules are fairly simple, you roll dice and total them for your score. The player who
has the highest total without going over 21 wins.
Each round begins with the dealer rolling 2 dice and outputting the total. The program will then
roll 2 dice for the user and show them the total as well. The user is then given the option of
rolling a single die and adding that to their total. They may continue rolling a die for as long as
they want to continue, or until they go over 21. Once the user is done, if they haven’t gone over
21 the dealer will continue to roll a die until they bust or tie/beat the player.
The program will start by asking the user for how much money they want in chips. This amount
must be greater than 0. Before each round it should ask them for their wager amount. The
wager is more than 0 and less than or equal to their pot. If the user wins a round their wager
gets added to their pot. If they lose, then the pot is decremented by the wager. If there is a tie,
then the pot is left alone. The player continues playing until they run out of money. In which
case they can begin play again by buying more chips or quitting.
Requirements
Your program will ask the user for an initial amount of money that the user will have.
This is their pot. They are allowed to keep playing as long as they have money left. The
user cannot enter a value <= 0. It must be a positive whole number. Do not worry about
the user entering floats or strings. We’ll learn how to deal with those later.
You should ask them how much they want to wager for each round. This amount has to
be greater than zero, and less than or equal to the amount they have left. Keep
prompting them for a correct amount until they have provided it. Again, we won’t worry
about the user entering anything malicious at this point.
The pot and wager will be integers.
Once the initial rolls are made, ask the user if they want to roll another die. The only
acceptable values are Y,YES,N or NO. Any other input give a warning and prompt for
input again.
The user rolls a single die as long as they want to and it gets added to their total. If they
bust ( go over 21), then they will not be asked to roll again and automatically lose.
Once the user loses all their money ( which is inevitable ), you should report how many
rounds played before they lost all their money, and the maximum amount of money they
had.
Once the user runs out of money ask the user if they want to play again. Valid
responses are Y, YES, N or NO. If they want to play more, then they can enter another
pot amount. If no, then the program ends.
If the user plays again don’t forget to reset the rounds played and maximum amount.
Development notes
To roll the dice, you need a way to generate random numbers. Fortunately, Python
includes just such a feature. To use it, make the first line of 'real' code (after your
opening comments):
import random
To generate a random whole number from 1 to 6:
d = random.randint(1,6)
Obviously, you can use whatever variable name you like other than d.
The string method .lower() produces a new string that is the lowercase version of a
string.
'ABC'.lower() == 'abc'
It can be useful in processing some of the user input. Its
use is not required.
There is also a .upper() method as well. ‘abc’.upper() produces ‘ABC’
The membership operator in can be useful as well. Its use is not required
Example. Take notice of the bad input.
>>> ================================ RESTART ================================
>>>
Welcome to Blackjack Dice
Enter the amount of money you want in chips. ==> $
-1
The amount must be greater than 0
Enter the amount of money you want in chips. ==> $
0
The amount must be greater than 0
Enter the amount of money you want in chips. ==> $
10
Enter the amount you want to wager. ==> $
-1
The wager must be greater than zero
Enter the amount you want to wager. ==> $
12
The wager cannot be greater than the amount you have in the pot
Enter the amount you want to wager. ==> $
5
Dealer rolled a 6 and a 2 for a total of 8
You rolled a 4 and a 5 for a total of 9
Do you want to roll again? (Y,YES,N,NO) ==>
e
You must enter Y,YES,N or NO
Do you want to roll again? (Y,YES,N,NO) ==>
y
You rolled a 6 for a total of 15
Do you want to roll again? (Y,YES,N,NO) ==>
y
You rolled a 3 for a total of 18
Do you want to roll again? (Y,YES,N,NO) ==>
y
You rolled a 6 for a total of 24
You busted, I'm so sorry
The dealer won this round, you've lost your $ 5 wager
You now have $ 5 in the pot
Enter the amount you want to wager. ==> $
5
Dealer rolled a 1 and a 1 for a total of 2
You rolled a 6 and a 6 for a total of 12
Do you want to roll again? (Y,YES,N,NO) ==>
y
You rolled a 5 for a total of 17
Do you want to roll again? (Y,YES,N,NO) ==>
y
You rolled a 3 for a total of 20
Do you want to roll again? (Y,YES,N,NO) ==>
n
You stayed on 20
The Dealer rolled 2 for a total of 4
The Dealer rolled 4 for a total of 8
The Dealer rolled 6 for a total of 14
The Dealer rolled 4 for a total of 18
The Dealer rolled 2 for a total of 20
You tied the dealer, it's a push
You now have $ 5 in the pot
Enter the amount you want to wager. ==> $
1
Dealer rolled a 2 and a 1 for a total of 3
You rolled a 3 and a 1 for a total of 4
Do you want to roll again? (Y,YES,N,NO) ==>
y
You rolled a 4 for a total of 8
Do you want to roll again? (Y,YES,N,NO) ==>
y
You rolled a 4 for a total of 12
Do you want to roll again? (Y,YES,N,NO) ==>
y
You rolled a 4 for a total of 16
Do you want to roll again? (Y,YES,N,NO) ==>
y
You rolled a 6 for a total of 22
You busted, I'm so sorry
The dealer won this round, you've lost your $ 1 wager
You now have $ 4 in the pot
Enter the amount you want to wager. ==> $
1
Dealer rolled a 3 and a 6 for a total of 9
You rolled a 3 and a 4 for a total of 7
Do you want to roll again? (Y,YES,N,NO) ==>
y
You rolled a 3 for a total of 10
Do you want to roll again? (Y,YES,N,NO) ==>
y
You rolled a 6 for a total of 16
Do you want to roll again? (Y,YES,N,NO) ==>
y
You rolled a 1 for a total of 17
Do you want to roll again? (Y,YES,N,NO) ==>
y
You rolled a 1 for a total of 18
Do you want to roll again? (Y,YES,N,NO) ==>
y
You rolled a 1 for a total of 19
Do you want to roll again? (Y,YES,N,NO) ==>
n
You stayed on 19
The Dealer rolled 2 for a total of 11
The Dealer rolled 3 for a total of 14
The Dealer rolled 2 for a total of 16
The Dealer rolled 2 for a total of 18
The Dealer rolled 1 for a total of 19
You tied the dealer, it's a push
You now have $ 4 in the pot
Enter the amount you want to wager. ==> $
1
Dealer rolled a 4 and a 5 for a total of 9
You rolled a 4 and a 2 for a total of 6
Do you want to roll again? (Y,YES,N,NO) ==>
y
You rolled a 4 for a total of 10
Do you want to roll again? (Y,YES,N,NO) ==>
y
You rolled a 3 for a total of 13
Do you want to roll again? (Y,YES,N,NO) ==>
y
You rolled a 3 for a total of 16
Do you want to roll again? (Y,YES,N,NO) ==>
y
You rolled a 5 for a total of 21
Do you want to roll again? (Y,YES,N,NO) ==>
n
You stayed on 21
The Dealer rolled 3 for a total of 12
The Dealer rolled 1 for a total of 13
The Dealer rolled 5 for a total of 18
The Dealer rolled 6 for a total of 24
Congratulations, you won $ 1
You now have $ 5 in the pot
Enter the amount you want to wager. ==> $
5
Dealer rolled a 5 and a 2 for a total of 7
You rolled a 1 and a 1 for a total of 2
Do you want to roll again? (Y,YES,N,NO) ==>
y
You rolled a 5 for a total of 7
Do you want to roll again? (Y,YES,N,NO) ==>
y
You rolled a 2 for a total of 9
Do you want to roll again? (Y,YES,N,NO) ==>
n
You stayed on 9
The Dealer rolled 4 for a total of 11
The dealer won this round, you've lost your $ 5 wager
You now have $ 0 in the pot
You ran out of money
You played 6 rounds. Your highest pot was 10
Do you want to play again? (Y,YES,N,NO) ==>
e
You must enter Y, YES, N or NO
Do you want to play again? (Y,YES,N,NO) ==>
n>>>