Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- __author__ = 'David Gotz, gotz@unc.edu, Onyen = gotz'
- import random
- # Simulates a random card drawing. Returns a dictionary with suit and value
- # keys.
- def draw_card():
- suit = random.choice(["Spades", "Clubs", "Diamonds", "Hearts"])
- value = random.randint(1,13)
- return {'suit': suit, 'value': value}
- # The main function
- def main():
- # Draw five cards, storing as an array.
- hand_of_cards = [draw_card(), draw_card(), draw_card(), draw_card(), draw_card()]
- # Print the hand of cards.
- for card in hand_of_cards:
- print(card['value'], "of", card['suit'])
- # Run the program
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement