Question: I hope someone can help me with this. Please document the code below by using python comments. import random class Card: def __init__(self, rank, suite):

I hope someone can help me with this. Please document the code below by using python comments.

import random

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

def getRank(self): return self.rank

def getSuite(self): return self.suite def setSuite(self,suit): self.suite = suit def setRank(self,rank): selt.rank = rank

def __str__(self): return ('{0} of {1}'.format(self.rank, self.suite))

def shuffled_deck(): deck = [] for suite in ['Clubs', 'Diamonds', 'Hearts', 'Spades']: for num in ['Ace', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King']: deck.append([num, suite]) random.shuffle(deck) return deck

def main(): deck = shuffled_deck() hand = [] while True: n = int(input('How many cards should I deal: ')) if n < 1 or n > 52: print('Please enter a number between 1-52! ') else: break for i in range(n): hand.append(deck[i]) print "Your "+str(n)+" dcards are: " for i in hand: print str(i[0])+" of "+ i[1]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!