User Tools

Site Tools


Sidebar

Dan's Wiki

DokuWiki Instructions (local) DokuWiki Manual
Site Checker (Orphans Wanted)

Edit Sidebar

projects:houseofcards:shufflecards

Python Shuffle Cards Routine

http://www.programiz.com/python-programming/examples/shuffle-card

# Python program to shuffle a deck of card using the module random and draw 5 cards
 
# import modules
import itertools, random
 
# make a deck of cards
deck = list(itertools.product(range(1,14),['Spade','Heart','Diamond','Club']))
 
# shuffle the cards
random.shuffle(deck)
 
# draw five cards
print("You got:")
for i in range(5):
   print(deck[i][0], "of", deck[i][1])
projects/houseofcards/shufflecards.txt · Last modified: 2016/07/15 01:53 by dwheele