Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. import random
  2. ranks = []
  3. suits = ['\u2660', '\u2661','\u2662', '\u2663']
  4. royals = ["J", "Q", "K", "A"]
  5. deck = []
  6.  
  7. #2.1 Build a class Card() that contains 2 variables: rank and suits
  8. class Card:
  9. ranks = ''
  10. suits = ''
  11. def __init__(self,rank,suit):
  12. self.rank = ranks
  13. self.suit = suits
  14. #2.2 Build a Deck that contains 52 cards with ranks and suits.
  15.  
  16. #add numbers 2-10 and converts them to string data
  17. for i in range(2,11):
  18. ranks.append(str(i))
  19. #add the royal faces to the ranks
  20. for j in range(4):
  21. ranks.append(royals[j])
  22. #attach the suits to it
  23. for k in range(4):
  24. for l in range(13):
  25. c = (ranks[l],suits[k])
  26. deck.append(card)
  27. random.shuffle(deck)
  28. deck[0].ranks
  29. deck[0].suits
  30.  
  31.  
  32. def playerTurn(deck):
  33. #Get the ranks of the first 2 cards from deck
  34. player_sum = deck[0].ranks + deck[1].ranks
  35.  
  36. #Remember to take care of J Q K A
  37.  
  38. return player_sum
  39.  
  40. #2.3 Two players will take turn to draw two cards from a shuffle decks.
  41. #It's time to play a round
  42. player1_sum = 0
  43. player2_sum = 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement