Part A: Using the Class Methods 1. Examine the Python statements in the file nam
ID: 3849974 • Letter: P
Question
Part A: Using the Class Methods 1. Examine the Python statements in the file named "labl la 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: Q4 Player #1 hand: [74, 10 Second card dealt to player #2: Q Player #2 hand EK 2 8 Last card in hand of player #1 7 Last card in hand of player #2: 8+ 8* of higher rank than 7 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 your TA. on-line students should submit the 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. 3. Revise the program to eliminate the invocation of function "random.seed Run the program several times and observe the results. Note: if function "random.seed" is not invoked, then the current system time is used to initialize the random number generatorExplanation / Answer
def random(one,two):
import random
number = random.randint(one,two)
return number
def suit():
suitnumber = random(1,4)
if suitnumber == 1:
suitb = 'Spade'
elif suitnumber == 2:
suitb = 'Hearts'
elif suitnumber == 3:
suitb = 'Diamonds'
elif suitnumber == 4:
suitb = 'Clubs'
return suitb
def number():
number = random(1,13)
if number == 13:
value = 'Ace'
elif number == 12:
value = 'King'
elif number == 11:
value = 'Queen'
elif number == 10:
value = 'Jack'
elif number < 10:
value = number
return value
def card():
cardnumber = number()
cardsuit = suit()
card = cardsuit,cardnumber
return card
def store10Cards():
tenCards = [card(),
card(),
card(),
card(),
card(),
card(),
card(),
card(),
card(),
card()]
return tenCards
def yourCards():
cards = store10Cards()
counter = 1
choice = int(input('Which of your cards would you want to see? You have 10 cards : '))
if choice == 1:
print('Your chosen card is',cards[0])
elif choice == 2:
print('Your chosen card is',cards[1])
elif choice == 3:
print('Your chosen card is',cards[2])
elif choice == 4:
print('Your chosen card is',cards[3])
elif choice == 5:
print('Your chosen card is',cards[4])
elif choice == 6:
print('Your chosen card is',cards[5])
elif choice == 7:
print('Your chosen card is',cards[6])
elif choice == 8:
print('Your chosen card is',cards[7])
elif choice == 9:
print('Your chosen card is',cards[8])
elif choice == 10:
print('Your chosen card is',cards[9])
import time
time.sleep(5)
return cards
print('Hi')
import time
time.sleep(2)
print('You have 10 cards')
time.sleep(2)
choice = input('Would you like to see them? Y/N : ')
choice = choice.title()
if choice == 'Y':
yourCards()
elif choice == 'N':
print('Too bad')
time.sleep(1)
import sys
sys.exit(0)