I need help on the following Python 3+ program: We are supposed to use the follo
ID: 3851004 • Letter: I
Question
I need help on the following Python 3+ program:
We are supposed to use the following skeleton files: cards.py, lab11a.py, and lab11b.py
These files can be found at: https://www.cse.msu.edu/~cse231/Labs/Lab11/
The instructions are:
Thank you!!
1. Examine the Python statements in the file named "lablia.py", then extend that program to do the following tasks a. Display each players' hand after the first card has been played from each hand. b. Display the second card dealt to each player and compare them. c. Display each players' hand after the second card has been played from each hand d. Display the last card dealt to each player and compare them. Here is the additional output after those modifcations Second card dealt to player 1: 24 Player #1 hand. [74, 10 7 Second card dealt to player #2: QA Player #2 hand. IK 2 8 Last card in hand of player #1 7 Last card in hand of player #2: 8 of higher rank than 7 8+ Note on Mirmir testing: you will notice that the symbols for the suits are not printed in the Mirmir tests instead the letters hcds are used. That is because Mimir cannot handle the symbols. You do not need to do anything about that it is built into the cards.py that we use for testing. Demonstrate your completed program to yourTA. on-line students should submit th completed program (named "labila py") for grading via the Mirmir system. Do steps 2 and 3 on your own without handing in to Mirmir: 2. Revise the program to use a different integer number as the argument in the invocation of function "random seed". Run the program several times and observe the results.Explanation / Answer
import random
creating the deck of cards
cards = ['8S', '7S', '6S', '5S', '4S', '3S', '2S',
'AD', 'KD', 'QD', 'JD', '10D', '9D', '8D', '7D', '6D', '5D', '4D', '3D', '2D',
'AC', 'KC', 'QC', 'JC', '10C', '9C', '8C', '7C', '6C', '5C', '4C', '3C', '2C',
'AH', 'KH', 'QH', 'JH', '10H', '9H', '8H', '7H', '6H', '5H', '4H', '3H', '2H']
player = input('How many players? ')
hand1 = []
hand2 = []
hand3 = []
hand4 = []
hand5 = []
hand6 = []
hand7 = []
hand8 = []
hand9 = []
hand10 = []
hand11 = []
hand12 = []
hand13 = []
hand14 = []
hand15 = []
#shuffle the cards
random.shuffle(cards)
num = input('How many cards to deal to each player? ')
while num > 0:
if player == 1:
hand1.append(cards.pop(0))
if player == 2:
hand1.append(cards.pop(0))
hand2.append(cards.pop(0))
if player == 3:
hand1.append(cards.pop(0))
hand2.append(cards.pop(0))
hand3.append(cards.pop(0))
if player == 4:
hand1.append(cards.pop(0))
hand2.append(cards.pop(0))
hand3.append(cards.pop(0))
hand4.append(cards.pop(0))
if player == 5:
hand1.append(cards.pop(0))
hand2.append(cards.pop(0))
hand3.append(cards.pop(0))
hand4.append(cards.pop(0))
hand5.append(cards.pop(0))
if player == 6:
hand1.append(cards.pop(0))
hand2.append(cards.pop(0))
hand3.append(cards.pop(0))
hand4.append(cards.pop(0))
hand5.append(cards.pop(0))
hand6.append(cards.pop(0))
if player == 7:
hand1.append(cards.pop(0))
hand2.append(cards.pop(0))
hand3.append(cards.pop(0))
hand4.append(cards.pop(0))
hand5.append(cards.pop(0))
hand6.append(cards.pop(0))
hand7.append(cards.pop(0))
if player == 8:
hand1.append(cards.pop(0))
hand2.append(cards.pop(0))
hand3.append(cards.pop(0))
hand4.append(cards.pop(0))
hand5.append(cards.pop(0))
hand6.append(cards.pop(0))
hand7.append(cards.pop(0))
hand8.append(cards.pop(0))
if player == 9:
hand1.append(cards.pop(0))
hand2.append(cards.pop(0))
hand3.append(cards.pop(0))
hand4.append(cards.pop(0))
hand5.append(cards.pop(0))
hand6.append(cards.pop(0))
hand7.append(cards.pop(0))
hand8.append(cards.pop(0))
hand9.append(cards.pop(0))
if player == 10:
hand1.append(cards.pop(0))
hand2.append(cards.pop(0))
hand3.append(cards.pop(0))
hand4.append(cards.pop(0))
hand5.append(cards.pop(0))
hand6.append(cards.pop(0))
hand7.append(cards.pop(0))
hand8.append(cards.pop(0))
hand9.append(cards.pop(0))
hand10.append(cards.pop(0))
if player == 11:
hand1.append(cards.pop(0))
hand2.append(cards.pop(0))
hand3.append(cards.pop(0))
hand4.append(cards.pop(0))
hand5.append(cards.pop(0))
hand6.append(cards.pop(0))
hand7.append(cards.pop(0))
hand8.append(cards.pop(0))
hand9.append(cards.pop(0))
hand10.append(cards.pop(0))
hand11.append(cards.pop(0))
if player == 12:
hand1.append(cards.pop(0))
hand2.append(cards.pop(0))
hand3.append(cards.pop(0))
hand4.append(cards.pop(0))
hand5.append(cards.pop(0))
hand6.append(cards.pop(0))
hand7.append(cards.pop(0))
hand8.append(cards.pop(0))
hand9.append(cards.pop(0))
hand10.append(cards.pop(0))
hand11.append(cards.pop(0))
hand12.append(cards.pop(0))
if player == 13:
hand1.append(cards.pop(0))
hand2.append(cards.pop(0))
hand3.append(cards.pop(0))
hand4.append(cards.pop(0))
hand5.append(cards.pop(0))
hand6.append(cards.pop(0))
hand7.append(cards.pop(0))
hand8.append(cards.pop(0))
hand9.append(cards.pop(0))
hand10.append(cards.pop(0))
hand11.append(cards.pop(0))
hand12.append(cards.pop(0))
hand13.append(cards.pop(0))
if player == 14:
hand1.append(cards.pop(0))
hand2.append(cards.pop(0))
hand3.append(cards.pop(0))
hand4.append(cards.pop(0))
hand5.append(cards.pop(0))
hand6.append(cards.pop(0))
hand7.append(cards.pop(0))
hand8.append(cards.pop(0))
hand9.append(cards.pop(0))
hand10.append(cards.pop(0))
hand11.append(cards.pop(0))
hand12.append(cards.pop(0))
hand13.append(cards.pop(0))
hand14.append(cards.pop(0))
num = num - 1
if player == 1:
print hand1
if player == 2:
print hand1
print hand2
if player == 3:
print hand1
print hand2
print hand3
if player == 4:
print hand1
print hand2
print hand3
print hand4
if player == 5:
print hand1
print hand2
print hand3
print hand4
print hand5
if player == 6:
print hand1
print hand2
print hand3
print hand4
print hand5
print hand6
if player == 7:
print hand1
print hand2
print hand3
print hand4
print hand5
print hand6
print hand7
if player == 8:
print hand1
print hand2
print hand3
print hand4
print hand5
print hand6
print hand7
print hand8
if player == 9:
print hand1
print hand2
print hand3
print hand4
print hand5
print hand6
print hand7
print hand8
print hand9
if player == 10:
print hand1
print hand2
print hand3
print hand4
print hand5
print hand6
print hand7
print hand8
print hand9
print hand10
if player == 11:
print hand1
print hand2
print hand3
print hand4
print hand5
print hand6
print hand7
print hand8
print hand9
print hand10
print hand11
if player == 12:
print hand1
print hand2
print hand3
print hand4
print hand5
print hand6
print hand7
print hand8
print hand9
print hand10
print hand11
print hand12
if player == 13:
print hand1
print hand2
print hand3
print hand4
print hand5
print hand6
print hand7
print hand8
print hand9
print hand10
print hand11
print hand12
print hand13
if player == 14:
print hand1
print hand2
print hand3
print hand4
print hand5
print hand6
print hand7
print hand8
print hand9
print hand10
print hand11
print hand12
print hand13
print hand14
print 'the cards remaining in the deck are: '
print cards
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.