Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Module Lob Assessment 5: Creating a Blackjack Simulator |What you need to do, part 1 Getting the Count of the Cards in a Create a

image text in transcribedimage text in transcribed
Module Lob Assessment 5: Creating a Blackjack Simulator |What you need to do, part 1 Getting the Count of the Cards in a Create a Deck of Cards Player's Hands Complete the create_standard deck() function, which Your cask is to complete the function stub creates a new dock. The deck itself must be a data get_count(player) . The function takes a player's hand, Howmore lin. The cards within the deck must be which is a list, as input. The function calculates and recur represented as cuples of the form fault, number), where the value of the player's hand. It should be noted that a the suit is a string that must be either hears, 'dubr. special mapping is required. Currently, in the deck. Jack 'spaden', or 'diamonds', and the number is an integer that has a value of 11, Queen has a value of 12, King has a must be one of the following 2, 3. 4, 3. 0. 7. 8. 9. 10, 11, 12. 13, or 14. Note that the number used to identify the card value of 13, and Ace has a value of 14. You need to ensure hot the following assocation Jack = 11, Queen = 12, King = that the Jack, Queen, and King cards all have a value of 10 13, and Ace = 14. In terms of value, the picture cards (Jack. Finally, for the purposes of this implementation, we will Queen, and Kingl all have a value of 10, and the Ace card only treat the Ace with a value of 11. has a walus of 11. The casino only wants you to Implement a simple implementation of blackjack, in that the first in 21 Task wing and special capes for checking for blackjack are not required. The deck should be Sorted in alphabetical order of the pok and then by on appending ingeger identifien for example: Ifduba', 21 [clubs', 3) .., [diamonds, 7) . Isplanest the "get_count' fraction to calcy "diamonds', 140. Cheers. 1. . . Capades. 141). Task Implement the "get count function to Implement the create_docking] function no create calculate the value of cards in a player's the deck of cards. T hand Drawing a Card from a Deck Unit Ten & hang gui_smart Ations the proper court ins player's hard. Your task is to complete the function stub draw_card(deck) . The function cakes a deck as the input. The function should randomly select a card from the deck gut_court returns the proper count in a player's hard. using the random,choice() method and then remove the card from the deck by completing the remove_card_from_the_deck( function. Once this is done. Checking whether a Player has Won the function needs to return the card that was selected. four cock In to complete the function srub Task (hack_par dicplayer ] . The fection when a player's hand us Inpur and reams "IN' IFthe Inperplayer has exactly's O Implement the draw_card() function which deals then it resume BUST. otherwise In mums Dir cards to the dealer and players and removes the corresponding card from the deck. Tank Implement the duck_serial) Sanction sa check if the player has won last or has room in hitPutting it All Together Implement the logic for the player. At each point that represents an The code has already been provided endpoint to the game (such as a bust, Your task is to now combine everything that prompts the user for an action and the count = 21, or the highest deck together to create the blackjack game stores this in plexknowion If the user value if both players stay), you need to that is defined in action is q, then the game quits. You return an appropriate value. For the wowthethwartwewoout function need to implement the part where the example, if the player wins, return 1, and n. In the first part of this task, you will user provides an h, which stands for "hit' if the dealer wins, then retum -1. implement the section marked with # [that is, for drawing a card), and s, which FIRST SECTION INSERT YOUR CODE HERE. For stands for 'stay' (that is, to stop drawing this first section, you should do the cards). After each card is drawn, the following: player's hand needs to be checked to see whether they have won, they are Create a list for the player called bust, or whether everything is okay You "player', which will hold the cards in the will need to player's hand, and then create another implement dunk sax player) and dlanka list for the dealer called 'dealer', which when opponent, start true) after each draw. will hold the cards in the dealer's hand. You then need to implement the third . Create a new deck of cards using section marked with # THIRD SECTION the contestedwoddad!) function. INSERT YOUR CODE HERE. For this third section, you should do the following: Draw two cards for each player and add them to the respective player's Implement the logic for the dealer. hands. The dealer will continue to 'hit' (that is, draw a new card) if the total count in Create two variables, one for each their hand is lower than 17. During each player, that stores the count of the "hit', you must check whether the dealer player's hands. The cards will be has won, is bust, or is in the range from displayed using 17 to 20 (inclusive). If the dealer has a the dudewolwork(player) function and total value in the range from 17 to 20 the window dealer opponent, [inclusive), then the dealer must stop start true) function. These functions have drawing cards. been written already but will need to be placed correctly. After this, if no winner/loser has been decided (that is, each of the players has You then need to implement the second opted to stay at some point), a final section marked with # SECOND SECTION comparison is made to see who has the INSERT YOUR CODE HERE. For this second highest total in their hands. The winner section, you should do the following: is the player with the highest total

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

Describe the characteristics of strong versus weak cultures.

Answered: 1 week ago