in python
111 T-Mobile LTE 19:05 16% O python 2) Programming Exercises:p 103/1, 2, 3- all of these exercises should be implemented in one file Deck.py Test all the operations, send the tests with your HW submission! Deek.py from randon Leport randrange from Card import Card elase Decks definit__(self) post creates a 52 card deck in standard order cards - for wait in Card. SUITS for rank in Card. RANSE cards.appendCard rank, uit)) self.carde - Cards **Cards late post. Returns the number of carda insa return leself.carda) det deal wat **Seal a single card pret self.si > O poet Returns the next card, and remove it from salt the deck is not empty, otherwise return false" If self.sin() > 0 return valt.card.ppt det shufflerseit shes the deck poate randomises the order of cardin self. cand self.cards tor icardis estados pod . ) card card Programming Exercises 1. Modity the Deck c to keep track of the current sle of the deck using an instance variables. Does this change the run-time efficiency of the size operation? Do a bit of research to answer this question Look into the functions provided by the Python randon module to simplify the shuffling code in the Deck class 3. Suppose we want to be able to place cards back into a deck. Modify the Deck ce to include the operations addTop, addBottom, and addRandom (the Inst e inserts the card at a random location in the deck). 2) Programming Exercises: p 103 / 1, 2, 3- all of these exercises should be implemented in one file Deck.py Test all the operations, send the tests with your HW submission! Deck.py from random import randrange from Card import Card class Deck: def __init_(self): "post: Creates a 52 card deck in standard order"** cards = [] for suit in Card. SUITS: for rank in Card. RANKS: cards.append(Card (rank, suit)) self.cards - cards def size (self): **Cards left post: Returns the number of cards in self"** return len(self.cards) def deal(self): **Deal a single card pre: self.size() > 0 post: Returns the next card, and removes it from self.card if the deck is not empty, otherwise returns False" if self.size() > 0: return self.cards.pop() elser return false def shuffle(self): Shuffles the deck post: randomizes the order of cards in self" self.size() cards = self.cards for i,card in enumerate(cards) : pos - randrange(in) cards[i] - cards [pos] cards[pos] = card Programming Exercises 1. Modify the Deck class to keep track of the current size of the deck using an instance variable. Does this change the run-time efficiency of the size operation? Do a bit of research to answer this question. 2. Look into the functions provided by the Python random module to simplify the shuffling code in the Deck class. 3. Suppose we want to be able to place cards back into a deck. Modify the Deck class to include the operations addTop, addBottom, and addRandom (the last one inserts the card at a random location in the deck). 111 T-Mobile LTE 19:05 16% O python 2) Programming Exercises:p 103/1, 2, 3- all of these exercises should be implemented in one file Deck.py Test all the operations, send the tests with your HW submission! Deek.py from randon Leport randrange from Card import Card elase Decks definit__(self) post creates a 52 card deck in standard order cards - for wait in Card. SUITS for rank in Card. RANSE cards.appendCard rank, uit)) self.carde - Cards **Cards late post. Returns the number of carda insa return leself.carda) det deal wat **Seal a single card pret self.si > O poet Returns the next card, and remove it from salt the deck is not empty, otherwise return false" If self.sin() > 0 return valt.card.ppt det shufflerseit shes the deck poate randomises the order of cardin self. cand self.cards tor icardis estados pod . ) card card Programming Exercises 1. Modity the Deck c to keep track of the current sle of the deck using an instance variables. Does this change the run-time efficiency of the size operation? Do a bit of research to answer this question Look into the functions provided by the Python randon module to simplify the shuffling code in the Deck class 3. Suppose we want to be able to place cards back into a deck. Modify the Deck ce to include the operations addTop, addBottom, and addRandom (the Inst e inserts the card at a random location in the deck). 2) Programming Exercises: p 103 / 1, 2, 3- all of these exercises should be implemented in one file Deck.py Test all the operations, send the tests with your HW submission! Deck.py from random import randrange from Card import Card class Deck: def __init_(self): "post: Creates a 52 card deck in standard order"** cards = [] for suit in Card. SUITS: for rank in Card. RANKS: cards.append(Card (rank, suit)) self.cards - cards def size (self): **Cards left post: Returns the number of cards in self"** return len(self.cards) def deal(self): **Deal a single card pre: self.size() > 0 post: Returns the next card, and removes it from self.card if the deck is not empty, otherwise returns False" if self.size() > 0: return self.cards.pop() elser return false def shuffle(self): Shuffles the deck post: randomizes the order of cards in self" self.size() cards = self.cards for i,card in enumerate(cards) : pos - randrange(in) cards[i] - cards [pos] cards[pos] = card Programming Exercises 1. Modify the Deck class to keep track of the current size of the deck using an instance variable. Does this change the run-time efficiency of the size operation? Do a bit of research to answer this question. 2. Look into the functions provided by the Python random module to simplify the shuffling code in the Deck class. 3. Suppose we want to be able to place cards back into a deck. Modify the Deck class to include the operations addTop, addBottom, and addRandom (the last one inserts the card at a random location in the deck)