Question: This was the existing code. This is the problem that we need to do. Exercise: Poker Write a function poker(num_cards) that draws num_cards cards at
This was the existing code.

This is the problem that we need to do. 
Exercise: Poker Write a function poker(num_cards) that draws num_cards cards at random from a standard 52-card deck of playing cards. The output should be a list containing the requested number of cards, chosen at random from the full deck. Each card should be its own string. For example, print(poker(2)) returns a list of two random cards, which can be ['C2', 'H3'], or ['S6', 'C12'] etc.. A standard deck of playing cards consists of 52 Cards in each of the 4 suits of Spades, Hearts, Diamonds, and Clubs. Each suit contains 13 cards: Ace (1), 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack (11), Queen (12), King (13). This is, sampling without replacement (why? because once you take this card out of the deck, you can no longer sample out this card again) The challenge is that we cannot first choose the suit and the number separately, because it is possible that num_cards = 52 . = In [31]: # Club = C, Diamond = D, Heart H, Spade = S # 1-13 (Jack 11, Queen 12, King = 13) import random def poker(num_cards): cards = [] for suit in ['c', 'D', 'H', for num in range (1,14): new = suit + str(num) cards.append(new) hand = random.sample(cards, num_cards) return sorted (hand) s'] : # for loop creates standard deck # random sample of 'count cards Following the Poker exercise in 1.3, can you write a function named poker2(hand card) that randomly distributes cards to multiple players? 1. Input parameter 'hand' means the number of hands/players, while 'card' means the number of cards each player should have at the end of you distribution 2. The product of 'hand' and 'card' must be less than or equal to 52, otherwise the game is invalid; in that case, your function should return the following communication, 'Please enter valid input parameters.' 3. If the product of 'hand' and 'card'
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
