The Card class has the attributes of value and suite, which describe the cards in a standard 52-card deck. The attribute value takes in the digits 1 to 10 as well as the standard face cards, Jack, Queen, and King. The suite attribute takes in the four suites, namely clubs, spades, hearts, and diamonds. Obviously, two cards are equal if they have the same value and suite. The CardSet class is just an ensemble of Card instances. To know which cards are in your set, just iterate through the cards via the view method. This gets a formatted list of your cards in the cards attribute. To add cards to your set, use the add_cards method. The Deck class is a child class of the CardSet class. To initialize a deck, all 52 cards from the standard deck must be added to it. For uniformity, place each suite in ascending value -- 1 to 10, then Jack, then Queen, then King. The suites must be placed in this order: clubs - spades - hearts - diamonds. Note that all the diamond- suited cards are at the top of the deck, while the clubs are at the bottom of the deck. To visualize: cards_in_deck = ["1 of clubs", "2 of clubs", ... "King of clubs", "1 of spades", "2 of spades", .. "King of spades", "1 of hearts", "2 of hearts", ... "King of hearts", "1 of diamonds", "2 of diamonds", ... "King of diamonds"] The cards inside a deck may also be shuffled. A seed argument is added for reproducibility. The peek method of the class allow you to peek at the top n cards. The default value for nis 5. Lastly, The draw method allows you to draw the top n cards of the deck and transfer these cards to a CardSet instance. The default value of n is 5. Note that the number of cards that you can draw cannot exceed the current number of cards in the deck. In this exercise, you will simulate drawing two sets, each with n cards from a shuffled deck.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Python

will give you high rating for the help!

Easy Python Problem (see pic): 

Guides are available on the template below on what code to put:

Template: 

### Template
import random

class Card:
    def __init__(self, value, suite):
        self.value = value
        self.suite = suite

    def __str__(self):
        return f"{self.value} of {self.suite}"

    def __eq__(self, other):
        """Check if two cards are the same"""
        # -- YOUR CODE HERE --

class CardSet:
    def __init__(self):
        self.cards = []

    def view(self):
        for card in self.cards:
            print(card)

    def add_cards(self, cards):
        """Add cards to your set"""
        # -- YOUR CODE HERE --

class Deck(CardSet):
    def __init__(self):
        """Initialize the 52-card set. Start from 1-11, then Jack, Queen, King, then by suite: clubs, spades, hearts, diamonds"""
        cards = []
        # -- YOUR CODE HERE --
        self.cards = cards

    def count_cards(self):
        """"Count the number of cards in a deck"""
        # -- YOUR CODE HERE --

    def shuffle(self, seed=None):
        """Shuffle your deck using a random seed"""
        random.seed(seed)
        # -- YOUR CODE HERE --

    def peek(self, number=5):
        """Show the top n cards of the stack. This is analogous to getting the last n cards then reversing it."""
        # -- YOUR CODE HERE --

    def draw(self, cardset, number=5):
        """Transfer the top n cards of the stack to your cardset."""
        # -- YOUR CODE HERE --


    def add_cards(self):
        pass

if __name__ == "__main__":
    seed, hand, peek = input().split(",")    

    myDeck = Deck()
    handA = CardSet()
    handB = CardSet()

    myDeck.shuffle(int(seed))

    for x in range(1,3):
        print(f"\nRound {x}:")

        myDeck.draw(handA, int(hand))
        myDeck.draw(handB, int(hand))        

        print("Hand A: ")
        handA.view()
        print("Hand B: ")
        handB.view()  

        myDeck.count_cards()
        if(x == 1):  
            print(f"\n{peek} Cards at the top: ")    
            myDeck.peek(int(peek))

 
EASY PYTHON PROGRAMMING TASK:
TASK:
Discussion:
The first line contains a comma-seperated string containing the integer seed, which is the seed for
In the code template below, you are given three classes: Card, CardSet, and Deck.
reproducibility, hand, the number of cards to draw per card set, and peek, the number of cards to peek at the
top of the deck. The input follows this format:
The Card class has the attributes of value and suite, which describe the cards in a standard 52-card deck. The
attribute value takes in the digits 1 to 10 as well as the standard face cards, Jack, Queen, and King. The suite
attribute takes in the four suites, namely clubs, spades, hearts, and diamonds. Obviously, two cards are equal
<seed>, <hand> , <peek>
if they have the same value and suite.
Output Format
The CardSet class is just an ensemble of Card instances. To know which cards are in your set, just iterate
through the cards via the view method. This gets a formatted list of your cards in the cards attribute. To add
See sample outputs
cards to your set, use the add_cards method.
Sample Input 0
The Deck class is a child class of the CardSet class. To initialize a deck, all 52 cards from the standard deck
must be added to it. For uniformity, place each suite in ascending value -- 1 to 10, then Jack, then Queen, then
King. The suites must be placed in this order: clubs - spades - hearts - diamonds. Note that all the diamond-
17,2,4
suited cards are at the top of the deck, while the clubs are at the bottom of the deck. To visualize:
Sample Output 0
cards_in_deck = ["1 of clubs", "2 of clubs",
"King of clubs", "1 of spades",
"2 of spades", ... "King of spades", "1 of hearts",
"2 of hearts",
"2 of diamonds",
Round 1:
"King of hearts", "1 of diamonds",
... "King of diamonds"]
Hand A:
8 of hearts
1 of hearts
Hand B:
7 of spades
Jack of spades
Cards Left: 48
The cards inside a deck may also be shuffled. A seed argument is added for reproducibility. The peek method
of the class allow you to peek at the top n cards. The default value for n is 5.
Lastly, The draw method allows you to draw the top n cards of the deck and transfer these cards to a CardSet
4 Cards at the top:
6 of spades
Queen of clubs
7 of diamonds
9 of hearts
instance. The default value of n is 5. Note that the number of cards that you can draw cannot exceed the
current number of cards in the deck.
In this exercise, you will simulate drawing two sets, each with n cards from a shuffled deck.
Round 2:
Hand A:
8 of hearts
1 of hearts
6 of spades
Queen of clubs
Hand B:
7 of spades
Jack of spades
7 of diamonds
9 of hearts
Cards Left: 44
Transcribed Image Text:EASY PYTHON PROGRAMMING TASK: TASK: Discussion: The first line contains a comma-seperated string containing the integer seed, which is the seed for In the code template below, you are given three classes: Card, CardSet, and Deck. reproducibility, hand, the number of cards to draw per card set, and peek, the number of cards to peek at the top of the deck. The input follows this format: The Card class has the attributes of value and suite, which describe the cards in a standard 52-card deck. The attribute value takes in the digits 1 to 10 as well as the standard face cards, Jack, Queen, and King. The suite attribute takes in the four suites, namely clubs, spades, hearts, and diamonds. Obviously, two cards are equal <seed>, <hand> , <peek> if they have the same value and suite. Output Format The CardSet class is just an ensemble of Card instances. To know which cards are in your set, just iterate through the cards via the view method. This gets a formatted list of your cards in the cards attribute. To add See sample outputs cards to your set, use the add_cards method. Sample Input 0 The Deck class is a child class of the CardSet class. To initialize a deck, all 52 cards from the standard deck must be added to it. For uniformity, place each suite in ascending value -- 1 to 10, then Jack, then Queen, then King. The suites must be placed in this order: clubs - spades - hearts - diamonds. Note that all the diamond- 17,2,4 suited cards are at the top of the deck, while the clubs are at the bottom of the deck. To visualize: Sample Output 0 cards_in_deck = ["1 of clubs", "2 of clubs", "King of clubs", "1 of spades", "2 of spades", ... "King of spades", "1 of hearts", "2 of hearts", "2 of diamonds", Round 1: "King of hearts", "1 of diamonds", ... "King of diamonds"] Hand A: 8 of hearts 1 of hearts Hand B: 7 of spades Jack of spades Cards Left: 48 The cards inside a deck may also be shuffled. A seed argument is added for reproducibility. The peek method of the class allow you to peek at the top n cards. The default value for n is 5. Lastly, The draw method allows you to draw the top n cards of the deck and transfer these cards to a CardSet 4 Cards at the top: 6 of spades Queen of clubs 7 of diamonds 9 of hearts instance. The default value of n is 5. Note that the number of cards that you can draw cannot exceed the current number of cards in the deck. In this exercise, you will simulate drawing two sets, each with n cards from a shuffled deck. Round 2: Hand A: 8 of hearts 1 of hearts 6 of spades Queen of clubs Hand B: 7 of spades Jack of spades 7 of diamonds 9 of hearts Cards Left: 44
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY