Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro SQL Server Wait Statistics

Authors: Enrico Van De Laar

1st Edition

1484211391, 9781484211397

More Books

Students also viewed these Databases questions

Question

2. How will the team select a leader?

Answered: 1 week ago