Question: Python Preliminaries: import random class Card: suit_sym = {0: 'u2663' , 1: 'u2666' , 2: 'u2665' , 3: 'u2660' } rank_sym = {0: '2' ,
Python
Preliminaries:
import random class Card: suit_sym = {0: '\u2663', 1: '\u2666', 2: '\u2665', 3: '\u2660'} rank_sym = {0: '2', 1: '3', 2: '4', 3: '5', 4: '6', 5: '7', 6: '8', 7: '9', 8: '10', 9: 'J', 10: 'Q', 11: 'K', 12: 'A'} def __init__(self, rank, suit): self.rank = rank self.suit = suit def __repr__(self): return self.rank_sym[self.rank] + self.suit_sym[self.suit] def __eq__(self, other): return self.suit == other.suit and self.rank == other.rank class Player: def __init__(self, card_list): self.card_list = card_list self.score = 0 def __repr__(self): return 'cards: ' + str(self.card_list) + ', score: ' + str(self.score) # Utility function to help with testing. Don't change this function. def build_deck(): card_list = [] for i in range(4): for j in range(13): card_list.append(Card(j, i)) return card_list # Utility function to help with testing. Don't change this function. def build_players(): player_list = [] for i in range(4): player = Player([]) player_list.append(player) return player_list
Part I: Deal the Cards (20 points) Write a function deal.cards ( that takes the following arguments, in this order: 1. player.list: A list of 4 Player objects. 2. card.list: A list of 52 Card objects. Your function should deal each Card object in card.list to each Player in player.list in the following order: 1. The first Card object in the card.list list is added to first Player object in player.list list. 2. The second Card object in the card.list list is added to second Player object in player.list list. 3. The third Card object in the card.list list is added to third Player object in player.list list. 4. The fourth Card object in the card.list list is added to fourth Player object in player.list list. 5. The fifth Card object in the card.list list is added to first Player object in player.list list and so on, up until the last Card object from card.list has been dealt. This function doesn't return any values
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
