Page 1 of 1

- Provide extensive documentation for the class and methods. - Do not import any packages other than random, even if you

Posted: Thu Jun 02, 2022 8:01 am
by answerhappygod
- Provide extensive documentation for the class and methods.
- Do not import any packages other than random, even if you don’t use those.
Provide Extensive Documentation For The Class And Methods Do Not Import Any Packages Other Than Random Even If You 1
Provide Extensive Documentation For The Class And Methods Do Not Import Any Packages Other Than Random Even If You 1 (40.12 KiB) Viewed 25 times
Provide Extensive Documentation For The Class And Methods Do Not Import Any Packages Other Than Random Even If You 2
Provide Extensive Documentation For The Class And Methods Do Not Import Any Packages Other Than Random Even If You 2 (40.12 KiB) Viewed 25 times
Provide Extensive Documentation For The Class And Methods Do Not Import Any Packages Other Than Random Even If You 3
Provide Extensive Documentation For The Class And Methods Do Not Import Any Packages Other Than Random Even If You 3 (40.12 KiB) Viewed 25 times
Provide Extensive Documentation For The Class And Methods Do Not Import Any Packages Other Than Random Even If You 4
Provide Extensive Documentation For The Class And Methods Do Not Import Any Packages Other Than Random Even If You 4 (40.12 KiB) Viewed 25 times
Provide Extensive Documentation For The Class And Methods Do Not Import Any Packages Other Than Random Even If You 5
Provide Extensive Documentation For The Class And Methods Do Not Import Any Packages Other Than Random Even If You 5 (32.58 KiB) Viewed 25 times
1. Implement the class for the card deck. In particular, you should implement the shuffle() method and the get_card(rank, suit) method. The shuffle() method works precisely like the permute() function we talked about in class, except that it's a method. The get_card(rank, suit) should return the card having the corresponding rank (0 is clubs, 1 is diamonds, 2 is hearts, and 3 is spades) and suit (0 is 2, 1 is 3,..., 12 is Ace). You may also modify or add whatever method necessary to the Deck class. (5 points). 2. Complete the main() function that will shuffle the deck 10 times, and prints out the deck content each time it's shuffled. The printout format should be as follows: Card1: 2, Card2: A., ... You may modify appropriate parts of the Deck class to achieve this. (4 points)
ANM4 in 672222222 import random # Don't modify the Card class class Card: def __init__(self, n): self._id = n self.suit_sym= ['\u2663', '\u2666', '\u2665', '\u2660'] self.rank_sym= ['2', '3', '6', '7', '8', '9', '10', '3', '0', 'K', 'A'] def suit(self): return self._id // 13 def rank(self): return self._id% 13 def _repr_(self): return self.rank sym[self.rank()] + self.suit_sym[self.suit()] class Deck: # You're allowed to modify the constructor. definit__(self): # TODO: Define the necessary methods def shuffle(self): 28 *** 29 30 def get_card(self, rank, suit): 31 32 33 def main(): 34 # TODO: Write a code that will shuffle the deck 10 times, and for each shuffle, print out the deck. # Deck printout format: 'Card 1: , Card 2: , ..., where is the card printout. 35 36 37 38 _main__': if name main() 39 40 1 2 3 5 8 9 10 11 12 13 14 15 16 17 18 19 20 21 23 24 25