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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started