Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 2 (20 points) Design a well-documented, Python program myCards.py to simulate shuffling 52 playing cards. In the simulation, the shuffled cards are turned up
Question 2 (20 points) Design a well-documented, Python program myCards.py to simulate shuffling 52 playing cards. In the simulation, the shuffled cards are turned up from the top until the first ace appears. Have your simulation estlmate how many cards are required, on average, to reveal the first ace by conducting the simulation 1,000,000 times. UNSHUFFLED DECK OF CARDS 13 26 39 12 25 27 38 40 SHUFFLED DECK OF CARDS Trial 1 13 Trial 2 Tenth Card, First Ace 39 Sixth Card, First Ace 0 39 13 26 AceAcece Ace 49th Card, First Ace AVERAGE POSITION OF FIRST ACE (10+6+491/3 In the simulation above, using three trials, the average position of the first ace is (10-6+493. On average, probability theory suggests that the first ace, of any suit, will be seen at 48/5 position within the deck Hint: One way of simulating a shuffled deck is by using the function sample within the random module. Here shuffleDeck random.sample(range(52), 52), is a list of shuffled cards
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