Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- ranks = []
- suits = ['\u2660', '\u2661','\u2662', '\u2663']
- royals = ["J", "Q", "K", "A"]
- deck = []
- #2.1 Build a class Card() that contains 2 variables: rank and suits
- class Card:
- ranks = ''
- suits = ''
- def __init__(self,rank,suit):
- self.rank = ranks
- self.suit = suits
- #2.2 Build a Deck that contains 52 cards with ranks and suits.
- #add numbers 2-10 and converts them to string data
- for i in range(2,11):
- ranks.append(str(i))
- #add the royal faces to the ranks
- for j in range(4):
- ranks.append(royals[j])
- #attach the suits to it
- for k in range(4):
- for l in range(13):
- c = (ranks[l],suits[k])
- deck.append(card)
- random.shuffle(deck)
- deck[0].ranks
- deck[0].suits
- def playerTurn(deck):
- #Get the ranks of the first 2 cards from deck
- player_sum = deck[0].ranks + deck[1].ranks
- #Remember to take care of J Q K A
- return player_sum
- #2.3 Two players will take turn to draw two cards from a shuffle decks.
- #It's time to play a round
- player1_sum = 0
- player2_sum = 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement