Question: Hello everyone, I would like some help in programming a blackjack python assignment. Thanks! Overview Blackjack, also know as twenty-one, is a card game that

Hello everyone, I would like some help in programming a blackjack python assignment. Thanks!

Overview

Blackjack, also know as twenty-one, is a card game that is played at casinos around the world. In casinos, players bet money on each hand (with, as you would expect in a casino, the odds stacked in favor of the dealer). Point-based variants of the game are also popular, including a large number of Blackjack Phone Apps for Andriod and iPhone. You can read more about the game on Wikipedia.

In this assignment we'll be developing a simplified version of Blackjack. Our version will proceed as follows:

At the start of a new hand, the player will be dealt two cards. The player will then choose, with a goal of obtaining a set of cards that sum as close to 21 as possible without going over, to either "HIT" (get an additional card to add to the player's hand) or "STAY" (stick with the player's existing hand of cards). If the sum of the values of all cards in a player's hand ever goes over 21, they player immediately loses the hand. We call this way of losing "going bust." If the player chooses to STAY before going bust (i.e., with a hand value of 21 or less), it becomes the dealer's turn.

For our game, the dealer is the computer. In the Basic Requirements, you should assign the computerized dealer a score at random within in the range 16-21. We'll look at a more sophisticated approach in the Advanced Requirements below. This computerized dealer score will then be compared to the player's total hand value. If the computer's score is greater than or equal to the player's total hand value (and not over 21), then the player loses the hand. Otherwise, the player wins!

The deck of cards: Traditionally, a deck of playing cards contains 52 cards, with 13 different card values (Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, and King), each of which is found in four distinct suits (Hearts, Diamonds, Spades, and Clubs). In this assignment, we'll ignore suits. For the Basic Requirements, we'll further simplify things to use a deck of cards that has the values from 1 through 10. Moreover, we'll ignore the fact that when playing with real cards, each card can only be used once in a given hand. These assumptions let us simplify the process of dealing a card to the generation of a random number in the range of 1 to 10. For this assignment's Advanced Requirements, we'll add some of this complexity back into the program.

Basic Requirements

Satisfying all basic requirements perfectly, with no points deducted for any reason, would earn a maximum score of 8 out of 10 for this assignment.

You are to implement the basic blackjack game as outlined above. It should provide clear prompts and displays to the user along they 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, compute the sum, and display it to the user. (Remember, a card is just a random number form 1 to 10).

Ask the user if he/she wishes to HIT or STAY.

Each time the user chooses to HIT, deal him/her a new card, update the total, and check to see if he/she has gone bust (over the limit of 21).

Eventually, the player will choose to stay or go bust. If the player goes bust, he/she automatically loses. If not, then the computer gets its turn.

Generate the computer's score and compare it to the player's score and determine who wins. The computer's score should be a random number between 16 and 21.

Ask the user if he or she is ready to play a new hand of blackjack. If so, your program should go to 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

get_player_score: handles the initial deal of two cards to the player and the "HIT or STAY" loop. It should return the final player score.

deal_card: generate a card value for the player (using random). This should be used within the getPlayerScore function. The value should be between 1 and 10.

get_dealer_score: generate the dealer's score (using random)

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.

The output produced by your program should be nearly identical to the sample output provided below. While the numbers will vary because of the use of random numbers, the prompts and messages printed to the console when using your program should match those in the sample output to receive full credit.

Advanced Requirements

Satisfying both the basic and advanced requirements perfectly, with no points deducted for any reason, will result in a full 10 out of 10 score for this assignment.

Expand on the basic requirements by extending your program as follows.

Make the function deal_card more sophisticated by accounting for Jacks, Queens and Kings. They all have the same value as a 10, which means that values of 10 should be four times more likely other values. Thanks to the power of functions, this change should not impact any of your code outside of the deal_card function.

Make the dealer more sophisticated. To do this, you'll need to make two extensions to your basic program:Make the function get_dealer_score more sophisticated by using individual cards to determine the value of the dealer's hand rather than simply choosing a random value. Your get_dealer_score function should behave as follows:

Deal two cards, and sum the value.

As long as the dealer's sum is below 16, deal another card and add it to the total.

When comparing the dealer's score to the player's score (step 6 in the basic requirements description), the computer can "go bust" as well as the human player. If the dealer's score goes over 21, the player should win.

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!