Question: I NEED HELP WRITING A PYTHON CODE, IT WOULD BE USFEL TO DIVID THE CODE FOR EACH CELL This is a blackjack program. In the

I NEED HELP WRITING A PYTHON CODE, IT WOULD BE USFEL TO DIVID THE CODE FOR EACH CELL

This is a blackjack program. In the beginning, you have $1000 to play the game.

For each game, you need to bet some money, say x dollars.

- if you win, your total money = 1000 + x

- if you lose, your total money = 1000 -x

- if you tie with the program, your money has no change.

You can play this game as many rounds as you have money. You can also choose to quit after each round.

Game Roles:

(1) At first, you, the player, need to bet some money. Then you will get two random cards.

(2) The card values:

- Ace: you can choice either 1 or 11 points

- Jack: value = 10 points

- Queen: value = 10 points

- King: value = 10 points

- Others: value = card face number

(3) Dealer also has two cards. If the deal draws an Ace, 50:50 for 1 point or 11 points

- the dealer's card and total points are unknown to the player

(4) Display player's two cards and the total points. After you see your first two cards, you have the chance to draw additional cards (hit), limited to 2 additional cards at most. You also can pass (stand).

(5) If you draw a additional card, dealer will do the same

(6) If points > 21, points = 0, bust apply to both you and dealer

(7) Then dealer total points will compare with yours

- if yours is higher than the dealer's, you win

- if equal, tie

- if yours is lower, you lose

(8) Now you finish one game.

The program will ask if the player player again or not. Player can play until you quit or no more money left

  • Ignore possible duplicated cards (shuffle can help)
  • Ignore the Blackjack(If you start (Ace & 10) )
  • 'Hit': ask for another card.
  • 'Stand':hold your total and end a game.
  • 'Bust': over 21 points

I NEED HELP WRITING A PYTHON CODE, IT WOULD BE USFEL TODIVID THE CODE FOR EACH CELL This is a blackjack program. In

the beginning, you have $1000 to play the game. For each game,

Before you start, please run the this cell first. Code is used for displaying cards, pause 3 seconds, and clear the scren # card_display.py: given module for card display # to use it: import card_display and rename it as cd from IPython.display import clear_output import card_display as cd import time #------- TEST Card Display--- # # for one card: use list cd.card_display(["jack_of_clubs"]) # display time. sleep (3) # pasue 2 seconds clear_output(wait=True) # clear the screen # more cards cd.card_display(["queen_of_diamonds", "ace_of_spades", "5_of_clubs", "10_of_diamo time. sleep(3) clear_output (wait=True) 5 10 s OL given function: draw a card for you. import random def draw_card(): This function will draw a random card from 52 poker cards for you input: none return: card_num: int type, between 1 to 13 card_name: String type for example: if card_num is 1, use "ace", for 11, use "jack"; 12 "queen"; and 1 for others, card no change. "ace_of_clubs" means ace of clubs; suit suit_num= random.randint(1,4) if suit_num -- 1: suit = "spades" elif suit_num == 2: suit = "clubs" elif suit_num -- 3: "hearts" else: suit = "diamonds" card_num = random.randint(1,13) if(card_num == 1): card_name ="ace" elif (card_num== 11): card_name ="jack" elif (card_num== 12): card_name ="queen" elif (card_num== 13): card_name="king" else: card_name=str(card_num) return card_num, card_name + "_of_" + suit -test card_num, card_name, draw_card() print("\t Card_num:", card_num, "\tCard_name:", card_name, ) cd.card_display([card_name]) Card_num: 1 Card_name: ace_of_spades Please continue from here to finish this gaem # function used to calculate each card's points # function used to calculate dealer's points # # # # # # # function for win-tie-Lose, and money updating The dealer total points will compare with yours if yours is higher than the dealer's, you win. Your total money - 1000 + x if equal, tie; your money has no change. if yours is Lower, you lose. Your total money = 1000 - X return the new balance. __main()_: This is a blackjack program. In the beginning, you have $1000 to play the game. Start a loop for many rounds if money > 0: (1) At first, you, the player, need to bet some money. (2) Then you will get two random cards and calculate total points. (3) The dealer will get two random cards too. The total points are unknown to the player (4) Display your cards (5) After you see your first two cards, you have the chance to draw additional cards (hit) or pass (stand). You are limited to 2 additional cards at most. (5) If you draw a additional card, dealer will do the same (6) If points > 21 at any time, points , bust apply to both you and dealer (7) Call money updating (8) Now you finish one game. Print the balance, and The program will ask if the player wants to play again or quit. Player can play the game until quit or no more money left. - end of game: display the player's balance! bye

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!