Question
The following code creates and shuffles a deck of cards. import random ##create deck suits = [Hearts,Diamonds, Spades, Clubs] deck = [] card = []
The following code creates and shuffles a deck of cards.
import random
##create deck
suits = ["Hearts","Diamonds", "Spades", "Clubs"]
deck = []
card = []
for suit in suits:
for r in range(1,14):
card.append(suit)
card.append(r)
deck.append(card)
card = []
#shuffle_deck
for i in range (len(deck)):
c1 = random.randint(0, len(deck) - 1) ## 0 - last position in list
c2 = random.randint(0, len(deck) - 1) ## 0 - last position in list
deck[c1], deck[c2] = deck[c2], deck[c1] ##swap cards
In this assignment, using python you are to simulate dealing a hand of five cards 10,000 times. You must create and reshuffle a deck with each hand.
You are to determine and output to the screen the number of times the hand is:
a full house (3 or one rand 2 or another rank) a flush (all same suit)
and four of a kind
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started