Python package for a deck of cards
Project description
Poker Hands from a Deck of Cards
An object model of cards is loaded into a deck, that is shuffled and dealt out as hands is packaged in the python module carddeck.
Carddeck is composed of four python classes: 1) cards, 2) deck, 3) pokerhands, and 4) errors. It is a concept used to exercise python setup, coding, documenting and packaging for pypi distribution.
Install from PyPi
pip install carddeck
Example
The defult of five cards in four hands are dealt after creating a deck, and shuffling it.
from carddeck.deck import deck
myD = deck()
myD.shuffle()
myD.deal()
myD.printHands()
--------
Outout:
['Q♥', '8♥', 'A♥', '2♠', '7♣']
['4♣', 'K♣', 'J♦', 'J♠', '4♦']
['4♥', '7♦', '9♥', '2♦', '10♠']
['2♥', 'Q♣', 'A♦', 'J♣', '5♦']
The four hands are evaluated using the PokerHands object.
from carddeck.pokerhands import PokerHands
myPH = PokerHands()
for i in range(0,len(myD.hands)):
theCards = myD.hands[i]
theHand = myPH.getHand(theCards)
print(theCards, theHand)
--------
['Q♥', '8♥', 'A♥', '2♠', '7♣'] High card: A
['4♣', 'K♣', 'J♦', 'J♠', '4♦'] Two pair: 4 and J
['4♥', '7♦', '9♥', '2♦', '10♠'] High card: 10
['2♥', 'Q♣', 'A♦', 'J♣', '5♦'] High card: A
The next deal from the remaining cards can then be evaluated.
myD.deal()
for i in range(0,len(myD.hands)):
theCards = myD.hands[i]
theHand = myPH.getHand(theCards)
print(theCards, theHand)
--------
['Q♥', '8♥', 'A♥', '2♠', '7♣'] High card: A
['4♣', 'K♣', 'J♦', 'J♠', '4♦'] Two pair: 4 and J
['4♥', '7♦', '9♥', '2♦', '10♠'] High card: 10
['2♥', 'Q♣', 'A♦', 'J♣', '5♦'] High card: A
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file carddeck-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: carddeck-0.1.3-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 057ddf3d3006dfde2520ba1605a3563efa81137a93ee943b34dbc199accb2669 |
|
MD5 | 3d6024f262b20e0e66e5fa5864cbf817 |
|
BLAKE2b-256 | 8f159b240017df5365daf21c951bc869b472d023980a61a70201718bf5c111cc |