SHARE
TWEET

Untitled

a guest Jun 20th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import random
  2.  
  3.     suits = ('Hearts', 'Diamonds', 'Spades', 'Clubs')
  4.     ranks = ('Two', 'Three', 'Four', 'Five', 'Six', 'Seven','Eight','Nine', 'Ten', 'Jack', 'Queen', 'King', 'Ace')
  5.     values = {'Two':2, 'Three':3, 'Four':4, 'Five':5, 'Six':6, 'Seven':7, 'Eight':8, 'Nine':9, 'Ten':10, 'Jack':10,
  6.              'Queen':10, 'King':10, 'Ace':11}
  7.  
  8.     playing = True
  9.  
  10.  
  11.  
  12.     class Card():
  13.         def __init__(self,suit,rank):
  14.             self.suit = suit
  15.             self.rank = rank
  16.  
  17.         def __str__(self):
  18.             return "{} of {}".format(self.rank,self.suit)
  19.  
  20.     card = Card(suits,ranks)
  21.  
  22.     class Deck():
  23.  
  24.         def __init__(self):
  25.             self.deck = []
  26.             for suit in suits:
  27.                 for rank in ranks:
  28.                     self.deck.append(Card(suit,rank)) <======= I want to know what is this performing?
  29.  
  30.         def __str__(self):
  31.             deck_comp = ""
  32.             for card in self.deck:
  33.                 deck_comp += "n" + card.__str__()
  34.             return "The card is" + deck_comp
  35.  
  36.         def shuffle(self):
  37.             random.shuffle(self.deck)
  38.  
  39.         def deal(self):
  40.             single_card = self.deck.pop()
  41.             return single_card
  42.  
  43.     deck = Deck
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top