Question
Use a Card Class with __init__( ), __str__( ) and 3 variables: rank, suit (strings) and BlackJack value. Adapt the following code to use said
Use a Card Class with __init__( ), __str__( ) and 3 variables: rank, suit (strings) and BlackJack value.
Adapt the following code to use said Class and create a list of 52 Card objects and then code a deal function that uses the returned deck:
def create_deck():
suits = [S,H,C,D]
special_values = {'Ace':1, 'King':10, 'Queen':10, 'Jack':10}
numbers = [Jack, 'King', 'Queen', Ace]
for i in range(2,11):
numbers.append(str(i))
deck = {}
for suit in suits:
for num in numbers:
if num.isnumeric():
deck[num + ' of ' + suit] = int(num)
else:
deck[num + ' of ' + suit] = special_values[num]
return deck
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started