Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. __author__ = 'David Gotz, gotz@unc.edu, Onyen = gotz'
  2.  
  3. import random
  4.  
  5.  
  6. # Simulates a random card drawing. Returns a dictionary with suit and value
  7. # keys.
  8. def draw_card():
  9. suit = random.choice(["Spades", "Clubs", "Diamonds", "Hearts"])
  10. value = random.randint(1,13)
  11. return {'suit': suit, 'value': value}
  12.  
  13.  
  14. # The main function
  15. def main():
  16. # Draw five cards, storing as an array.
  17. hand_of_cards = [draw_card(), draw_card(), draw_card(), draw_card(), draw_card()]
  18.  
  19. # Print the hand of cards.
  20. for card in hand_of_cards:
  21. print(card['value'], "of", card['suit'])
  22.  
  23.  
  24. # Run the program
  25. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement