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 he/she wishes to HIT or STAY.
Each time the user chooses to HIT, deal him/her and the dealer a new card, update the total, and check to see if he/she or the dealer has gone bust (over the limit of 21).
Eventually, the player will choose to stay or go bust. Also, the dealer can go bust. If the player goes bust, he/she 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 1. 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.
set_card_deck: create a card deck from an input file (cards.txt). Then, return 52 cards saved in a list of lists.
deal_card: draw one card (i.e., one of the inner lists (e.g.,["Ace","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.
initial_deal: deals two cards by using the deal_card() function. Check whether either the player or dealer got two Aces. If so, change the sum of cards to 12. Then, return scores for the player and dealer and the card deck.
get_score: 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!