(Game: pick a card ) Write a program that simulates picking a card from a deck of 52 cards. Your program should display the rank (Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King) and suit (Clubs, Diamonds, Hearts, Spades) of the card.
Here is a sample run of the program:
The card you picked is the Jack of Hearts
Game: pick a card Program Code:
import random
# Define the ranks and suits of a deck of cards
ranks = ['Ace', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King']
suits = ['Clubs', 'Diamonds', 'Hearts', 'Spades']
# Randomly select a rank and suit for the card
rank = random.choice(ranks)
suit = random.choice(suits)
# Display the picked card
print("The card you picked is the", rank, "of", suit)
Executed Output 1:
The card you picked is the Queen of Clubs
Executed Output 2:
The card you picked is the 10 of Hearts