||| u to your mit lk the X + 1 from itertools import product 2 from random import choice, seed 3 from os import linesep 4 5 6 suits = {'hearts', 'clubs', 'spades', 'diamonds'} 7 numbers = set([i for i in range (2,15)]) 8 a = 551 9 seed(a) 10 11 def create_standard_deck(): 123 12 13 14 15 def get_all_cards (deck): 16 17 18 19 20 21 22 23 24 25 25 blackjack.py 26 19 def get_all_twos (deck): 23 def get_all_aces (deck): 661838888 41 pass 27 def get_card_number(deck, card_number): 28 29 42 pass 30 31 def get_card_suit (deck, suit): 32 I 33 34 35 def get_number_and_suit (deck, num, suit): 36 37 44 pass 45 46 pass 39 def remove_card_from_deck (deck, suit, num): 40 pass pass pass 43 def remove_suit_from_deck (deck, suit): pass pass

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Best Practices to Follow: It’s worth breaking up each functional task in create_blackjack_game() into separate functions. For example, a function to check the score of a player’s hand, to check whether a player has won, and so on. This entire implementation can be done neatly in about eight functions. Create a Deck of Cards Complete the create_standard_deck() function, which creates a new deck. The deck itself must be a data structure list. The cards within the deck must be represented as tuples of the form (suit, number), where the suit is a string that must be either ‘hearts’, ‘clubs’, ‘spades’, or ‘diamonds’, and the number is an integer that must be one of the following: 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, or 14. Note that the number used to identify the card has the following association: Jack = 11, Queen = 12, King = 13, and Ace = 14. In terms of value, the picture cards (Jack, Queen, and King) all have a value of 10, and the Ace card has a value of 11. The casino only wants you to implement a simple implementation of blackjack, in that the first to 21 wins, and special cases for checking for blackjack are not required. The deck should be sorted in alphabetical order of the suit, and then by an ascending integer identifier; for example: [(‘clubs’, 2), (‘clubs’, 3), ..., (‘diamonds’, 2), ..., (‘diamonds’, 14), (‘hearts’, 2), ... , (‘spades’, 14)]. Task Implement the create_deck() function to create the deck of cards. Drawing a Card from a Deck Your task is to complete the function stub draw_card(deck). The function takes a deck as the input. The function should randomly select a card from the deck 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, the function needs to return the card that was selected. Task Implement the draw_card() function which deals cards to the dealer and players and removes the corresponding card from the deck. Getting the Count of the Cards in a Player’s Hands Your task is to complete the function stub get_count(player). The function takes a player’s hand, which is a list, as input. The function calculates and returns the value of the player’s hand. It should be noted that a special mapping is required. Currently, in the deck, Jack has a value of 11, Queen has a value of 12, King has a value of 13, and Ace has a value of 14. You need to ensure that the Jack, Queen, and King cards all have a value of 10. Finally, for the purposes of this implementation, we will only treat the Ace with a value of 11. Task Implement the `get_count` function to calculate the value of cards in a player's hand. Checking whether a Player has Won Your task is to complete the function stub check_cards(player). The function takes a player’s hand as input and returns ‘WIN’ if the input player has exactly a count of 21. If they have a count that is greater than 21, then it returns ‘BUST’; otherwise, it returns ‘OK’. Task Implement the check_cards() function to check if the player has won, lost, or has room to hit.
earning X
tml?deploymentid=5982712319543488825160515008&elSBN=9780357421802&snapsh... Q
=
a
you to
your
on your
submit
click the
+
T blackjack.py
X +
1 from itertools import product
2 from random import choice, seed
3 from os import linesep
4
5
6 suits = {'hearts', 'clubs', 'spades', 'diamonds' }
7 numbers = set([i for i in range (2,15)])
8 a = 551
9 seed (a)
10
11 def create_standard_deck():
12
13
pass
14
15 def get_all_cards (deck):
16
17
pass
18
19 def get_all_twos (deck):
20
21
22
23 def get_all_aces (deck):
24
25
26
27 def get_card_number(deck, card_number):
28
29
pass
45
46
pass
30
31 def get_card_suit (deck, suit):
32
33
pass
pass
34
35 def get_number_and_suit (deck, num, suit):
36
37
pass
38
39 def remove_card_from_deck (deck, suit, num):
40
pass
41
42
43 def remove_suit_from_deck (deck, suit):
44
%
pass
/12
I
G Search or type URL
A
MacBook Pro
&
☆
*
+
O
)
(¹))
I
D
Fr
J Pausa
+
as
Transcribed Image Text:earning X tml?deploymentid=5982712319543488825160515008&elSBN=9780357421802&snapsh... Q = a you to your on your submit click the + T blackjack.py X + 1 from itertools import product 2 from random import choice, seed 3 from os import linesep 4 5 6 suits = {'hearts', 'clubs', 'spades', 'diamonds' } 7 numbers = set([i for i in range (2,15)]) 8 a = 551 9 seed (a) 10 11 def create_standard_deck(): 12 13 pass 14 15 def get_all_cards (deck): 16 17 pass 18 19 def get_all_twos (deck): 20 21 22 23 def get_all_aces (deck): 24 25 26 27 def get_card_number(deck, card_number): 28 29 pass 45 46 pass 30 31 def get_card_suit (deck, suit): 32 33 pass pass 34 35 def get_number_and_suit (deck, num, suit): 36 37 pass 38 39 def remove_card_from_deck (deck, suit, num): 40 pass 41 42 43 def remove_suit_from_deck (deck, suit): 44 % pass /12 I G Search or type URL A MacBook Pro & ☆ * + O ) (¹)) I D Fr J Pausa + as
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 5 images

Blurred answer
Knowledge Booster
Linux
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education