# Module: test3.py # Simulate 100,000 poker hands and tabulate # the number of hands obtained of each type. import random from card import Card from constants import * from pokerhand import PokerHand # Initialize list to record number of # occurrences of each hand type. # [0] * 10 is a list of 10 zeros. hand_types = [0] * 10 total = 0 # Repeat 10 deals 10,000 times for a total of # 100,000 poker hands. for n in range(0, 10000): # Create and shuffle new deck of 52 cards. deck = [ ] for suit in ['C', 'D', 'H', 'S']: for rank in range(2, 15): deck.append(Card(rank, suit)) random.shuffle(deck) # 10 poker hands can be dealt from a deck. for i in range(0, 10): # Create a poker hand from cards dealt # from the deck cards = [ ] for j in range(0, 5): cards.append(deck.pop( )) ph = PokerHand(cards) # Add one to list item that corresponds # to the hand type obtained. hand_types[ph.hand_type( )] += 1 print(hand_types)