Implementation of the deck collection type.
Project description
Deck
Deck is an implementation of the deck collection type, commonly confused with collections.deque.
>>> from deck import Deck
>>> d = Deck()
>>> d.shuffle()
>>> d.deal()
Card(<Suit.Diamonds: '♦'>, <Value.Two: 2>)
>>> d.deal()
Card(<Suit.Diamonds: '♦'>, <Value.Three: 3>)
>>> d.deal()
Card(<Suit.Hearts: '♥'>, <Value.Ten: 10>)
>>> d.deal()
Card(<Suit.Diamonds: '♦'>, <Value.Nine: 9>)
Deck supports cheating, if that's how you want to play.
>>> d.deal_from_bottom()
Card(<Suit.Spades: '♠'>, <Value.Five: 5>)
Importing the deck module also globally corrects other typographical errors that may occur in your code.
>>> import deck
>>> from collections import deck
>>> deck
<class 'deck.Deck'>
Taking this module too seriously would be a mistake.
However, if you want to use it to write a Poker game, the get_poker_hand function will help.
>>> from deck import Deck, get_poker_hand
>>> d = Deck(include_jokers=False)
>>> d.shuffle()
>>> p1 = [d.deal() for _ in range(5)]
>>> p2 = [d.deal() for _ in range(5)]
>>> if get_poker_hand(p1) > get_poker_hand(p2):
... print("Player 1 wins!")
...
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 Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file deck-3.0.0.tar.gz.
File metadata
- Download URL: deck-3.0.0.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.27.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
701a74566951ca3dd7a6c0bc6b45a348060cfae7e2093a1bf814417632daa896
|
|
| MD5 |
a6f60b23b4cc9c4d19c3589ca2139706
|
|
| BLAKE2b-256 |
c197eb3d672139350610366fe274782e64238c93d2b16fc70519aa04e0591f1b
|
File details
Details for the file deck-3.0.0-py3-none-any.whl.
File metadata
- Download URL: deck-3.0.0-py3-none-any.whl
- Upload date:
- Size: 3.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.27.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6df7a9743d55ebd1fc21fed77a1b8a52c274ed90cb40232ec61352ce7bbe5010
|
|
| MD5 |
ac99cbf70c54789b639110149e9d6a36
|
|
| BLAKE2b-256 |
1fa1abe4fd1d3c88a01bce4afcb59eaf481b815b5400d1763653eb47afef6f51
|