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

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!