Please answer it in Python Write a function distribute_cartes that has two mandatory arguments card and players and an optional argument nb_card whose default value is 10. The pick argument corresponds to the complete list of cards in the game, already shuffled. The players list corresponds to the list of player names. This function allows the action of distributing nb_card cards from the pickaxe to each of the players. She builds a djeux dictionary whose keys are the names of the players and associating with each name the list of cards corresponding to her game. We will make sure to sort the game of each player in ascending order using the spell function. The distribute_card function returns the dictionary and modifies its pickaxe argument by edge effet (cards dealt to players must be removed from the pickaxe). It is assumed here that the pickaxe contains sufficiently cards for all players. For example card = [74, 72, 59, 82, 44, 77, 17, 11, 62, 97, 83, 69, 100, 22, 4, 51, 55, 50, 103, 52, 13, 25, 38, 37, 29, 104, 47, 23, 39, 80, 49, 98, 8, 78, 26, 46, 86, 18, 93, 31, 27, 34, 85, 84, 76, 87, 65, 35, 81, 79, 101, 66, 20, 91, 73, 16, 102, 42, 40, 70, 90, 7, 6, 64, 14, 67, 43, 12, 58, 1, 63, 2, 75, 32, 48, 96, 3, 15, 99, 68, 53, 61, 56, 92, 36, 28, 19, 5, 24, 45, 57, 94, 21, 54, 88, 33, 10, 71, 30, 95, 9, 41, 60, 89] players = ['rara', 'riri', 'rere'] distribute_cartes(card,players,nb_card=10) #return => {'rara': 74, 72, 59, 82, 44, 77, 17, 11, 62, 97, 'riri': 83, 69, 100, 22, 4, 51, 55, 50, 103, 52 , rere: 13, 25, 38, 37, 29, 104, 47, 23, 39, 80}
Please answer it in Python
Write a function distribute_cartes that has two mandatory arguments card and players and an optional argument nb_card whose default value is 10. The pick argument corresponds to the complete list of cards in the game, already shuffled. The players list corresponds to the list of player names. This function allows the action of distributing nb_card cards from the pickaxe to each of the players. She builds a djeux dictionary whose keys are the names of the players and associating with each name the list of cards corresponding to her game. We will make sure to sort the game of each player in ascending order using the spell function. The distribute_card function returns the dictionary and modifies its pickaxe argument by edge effet (cards dealt to players must be removed from the pickaxe). It is assumed here that the pickaxe contains sufficiently cards for all players.
For example
card = [74, 72, 59, 82, 44, 77, 17, 11, 62, 97, 83, 69, 100, 22, 4, 51, 55, 50, 103, 52, 13, 25, 38, 37, 29, 104, 47, 23, 39, 80, 49, 98, 8, 78, 26, 46, 86, 18, 93, 31, 27, 34, 85, 84, 76, 87, 65, 35, 81, 79, 101, 66, 20, 91, 73, 16, 102, 42, 40, 70, 90, 7, 6, 64, 14, 67, 43, 12, 58, 1, 63, 2, 75, 32, 48, 96, 3, 15, 99, 68, 53, 61, 56, 92, 36, 28, 19, 5, 24, 45, 57, 94, 21, 54, 88, 33, 10, 71, 30, 95, 9, 41, 60, 89]
players = ['rara', 'riri', 'rere']
distribute_cartes(card,players,nb_card=10)
#return =>
{'rara': 74, 72, 59, 82, 44, 77, 17, 11, 62, 97, 'riri': 83, 69, 100, 22, 4, 51, 55, 50, 103, 52 , rere: 13, 25, 38, 37, 29, 104, 47, 23, 39, 80}
Step by step
Solved in 2 steps with 2 images