Answered step by step
Verified Expert Solution
Question
1 Approved Answer
NOTE : Is learning Python programming (currently on chapter 9) with the following textbook: Book Starting Out With Python 3rd Edition by Gaddis
NOTE: Is learning "Python programming" (currently on chapter 9) with the following textbook:
Book "Starting Out With Python" 3rd Edition by Gaddis
HERE ARE HOW "CARD_DEALER.PY" LOOKS LIKE
2. Previously in this chapter you saw the card dealer.py program that simulates cards being dealt from a deck. Enhance the program so it simulates a simplified version of the game of Blackjack between two virtual players. The cards have the following values Numeric cards are assigned the value they have printed on them. For example, the value of the 2 of spades is 2, and the value of the 5 of diamonds is 5. Jacks, queens, and kings are valued at 10 A131 Programming Assignment * Aces are valued at I or 11, depending on the player's choice. The program should deal cards to each player until one player's hand is worth more than 21 points. When that happens, the other player is the winner. (It is possible that both players' hands will simultaneously exceed 21 points, in which case neither player wins.) The program should repeat until all the cards have been dealt from the deck. If a player is dealt an ace, the program should decide the value of the card according to the following rule: The ace will be worth 11 points, unless that makes the player's hand exceed 21 points. In that case, the ace will be worth 1 point. ~/workspace/HW/ $ python number02.py Player one wins! Final hands Player one: 4 of Spades, 5 of Spades, King of Diamonds, Ace of Spades Player two: 8 of Diamonds, 6 of Hearts, 6 of Spades, 2 of Diamonds ~/workspace/HW/ $ python number02.py Player two wins! Final hands Player one: King of Diamonds, King of Spades, 2 of Hearts Player two: 5 of Hearts, Jack of Hearts /workspace/HW/ $ python number02.py Player one wins! Final hands Player one: 7 of Clubs, Jack of Spades, 4 of Hearts Player two: Jack of Hearts, Jack of Diamonds, Queen of Hearts 2. Previously in this chapter you saw the card dealer.py program that simulates cards being dealt from a deck. Enhance the program so it simulates a simplified version of the game of Blackjack between two virtual players. The cards have the following values Numeric cards are assigned the value they have printed on them. For example, the value of the 2 of spades is 2, and the value of the 5 of diamonds is 5. Jacks, queens, and kings are valued at 10 A131 Programming Assignment * Aces are valued at I or 11, depending on the player's choice. The program should deal cards to each player until one player's hand is worth more than 21 points. When that happens, the other player is the winner. (It is possible that both players' hands will simultaneously exceed 21 points, in which case neither player wins.) The program should repeat until all the cards have been dealt from the deck. If a player is dealt an ace, the program should decide the value of the card according to the following rule: The ace will be worth 11 points, unless that makes the player's hand exceed 21 points. In that case, the ace will be worth 1 point. ~/workspace/HW/ $ python number02.py Player one wins! Final hands Player one: 4 of Spades, 5 of Spades, King of Diamonds, Ace of Spades Player two: 8 of Diamonds, 6 of Hearts, 6 of Spades, 2 of Diamonds ~/workspace/HW/ $ python number02.py Player two wins! Final hands Player one: King of Diamonds, King of Spades, 2 of Hearts Player two: 5 of Hearts, Jack of Hearts /workspace/HW/ $ python number02.py Player one wins! Final hands Player one: 7 of Clubs, Jack of Spades, 4 of Hearts Player two: Jack of Hearts, Jack of Diamonds, Queen of Hearts
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started