Question: Create a program that prints out N random cards, like dealing out cards to a player. You will use a standard deck of playing cards

Create a program that prints out N random cards, like dealing out cards to a player. You will use a standard deck of playing cards (52). This problem will give you practice with functions, lists, and loops. A standard deck of playing cards: In case you are not familiar with a standard deck of 52 cards, they are split up into 4 suits: Hearts, Diamonds, Spades, Clubs. Inside each suit there are 13 cards (13*4=52): Ace, 2,3,4,5,6,7,8,9,10, Jack, Queen, King. Program requirements: The program will prompt the user to enter the number of cards to draw and pass this value to the function for picking cards. The program will pick that number of cards randomly from the list you create and print them out. The program should contain at a minimum 1 list and 1 function. Populate a list to represent all 52 cards. Represent each card's values as a string (How you do this is up to you). You may abbreviate the suits (H,D,S,C) internally if you wish, but be consistent, and be sure to expand for the final print out. o You can create this list manually, but its a bit painful. Better to think about how you can use nested loops to do this. Your program should not pick the same card twice. This means you will have to remove the selected card from the list before choosing another. The program will need to import random module. The function should be called pick_random_cards(...). o It will randomly select the number of cards requested from the 52 cards, and return a new list only containing the cards selected. o The function has one input: The number of cards to return. o The function has one output: A list containing the cards randomly picked. o Do not print out the cards inside the function Example program input and output: How many cards do you want [1-52]?3 Cards drawn: Ace of Hearts, 5 of Clubs, King of Spades. In the example above, you can see that it prompted the user for a number of cards. It then printed out 3 cards using their full names. "Ace of Hearts", "5 of Clubs", "King of Spades". No need to perform any error checking for non-numerical input, but be sure to print an appropriate error message for negative numbers, 0, and values greater than 52

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 Programming Questions!