Question: You are to implement the basic blackjack game as outlined above. It should provide clear prompts and displays to the user along the way. These
You are to implement the basic blackjack game as outlined above. It should provide clear prompts and displays to the user along the way. These prompts should be clear enough to tell the user all they need to play the game and to determine who wins each hand. The basic flow of the game should be as follows:
Deal two cards to the user and two cards to the dealer, compute the sum of the player and display it to the user.
Ask the user if heshe wishes to HIT or STAY.
Each time the user chooses to HIT, deal himher and the dealer a new card, update the total, and check to see if heshe or the dealer has gone bust over the limit of
Eventually, the player will choose to stay or go bust. Also, the dealer can go bust. If the player goes bust, heshe automatically loses. If the player does not go bust, but the dealer goes bust, then the dealer loses. If any of them goes bust, then you need to display the result. If none of them goes bust and the player chooses to stay, then you need to make the decision of who wins the game and display the result.
Ask the user if he or she is ready to play a new hand of blackjack. If so your program should go back to step If not, your program should quit.
Developing the solution for this program would be quite challenging without using functions. To make your job easier, think about how functions can be used to simplify the design. Your solution should have, at a minimum, the following functions:
main: the main function, which should have the main loop that repeats for each hand.
setcarddeck: create a card deck from an input file cardstxt Then, return cards saved in a list of lists.
dealcard: draw one card ie one of the inner lists egAce"Heart" randomly using random.choice and process the numeric value accordingly. Remove the withdrawn card from the card deck and return the numeric card value and the card deck.
initialdeal: deals two cards by using the dealcard function. Check whether either the player or dealer got two Aces. If so change the sum of cards to Then, return scores for the player and dealer and the card deck.
getscore: handles the initial deal of two cards to the player and the dealer and the "HIT or STAY" loop for other cards. It should return the final player score and the dealer score to the main function.
You may find that additional functions are useful to modularize your design. Adding more functions when appropriate is perfectly fine! However, the four functions identified above are REQUIRED. Also, I shared a skeleton code that will help you complete this assignment. You should start from the skeleton code.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
