This project has been archived by its maintainers, and is no longer receiving any updates.
nbdev_cards
A deck of cards demo of nbdev based on ideas from “Think Python 2nd Edition” by Allen B. Downey.
pip install
The nbdev-cards2022 package was uploaded to PyPI and can be easily installed using the below command.
pip install nbdev-cards2022
conda install
The nbdev-cards2022 was also uploaded to Anaconda and can be installed using the below command.
conda install -c hdocmsu nbdev-cards2022
How to use
import the card and deck modules
from nbdev_cards.card import *
from nbdev_cards.deck import *
This lib provids a
Card class
that you can use to create, display, and compare playing cards.
Card(2,3)
3♥
display all suits
suits
['♣', '♦', '♥', '♠']
display all ranks
ranks
[None, 'A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K']
Deck class can
be called to generate a deck of playing card. Initially, the deck is
ordered.
deck = Deck()
deck
A♣; 2♣; 3♣; 4♣; 5♣; 6♣; 7♣; 8♣; 9♣; 10♣; J♣; Q♣; K♣; A♦; 2♦; 3♦; 4♦; 5♦; 6♦; 7♦; 8♦; 9♦; 10♦; J♦; Q♦; K♦; A♥; 2♥; 3♥; 4♥; 5♥; 6♥; 7♥; 8♥; 9♥; 10♥; J♥; Q♥; K♥; A♠; 2♠; 3♠; 4♠; 5♠; 6♠; 7♠; 8♠; 9♠; 10♠; J♠; Q♠; K♠
shuffle() method could be used to shuffle the deck.
deck.shuffle()
deck
Q♥; 6♥; 4♥; Q♣; 8♥; K♣; A♦; Q♠; 7♠; 5♦; J♣; J♥; 6♠; A♣; 9♥; 9♣; J♠; A♠; 10♥; 3♥; 7♦; K♠; 4♠; 2♦; 5♠; K♦; 10♣; 5♣; 4♦; 8♣; 7♣; 10♠; Q♦; K♥; A♥; 7♥; 6♦; 3♠; 3♦; 9♦; 4♣; 6♣; 3♣; 8♦; 5♥; 9♠; 10♦; 2♠; J♦; 8♠; 2♥; 2♣
draw_n() function can be used to draw n card with or without
replacement.
let’s draw 10 cards with replacement.
draw_n(10, replace=True)
[10♦, 3♣, 6♦, Q♦, 3♥, K♠, 4♣, K♣, 3♣, 2♦]
now let’s draw 10 cards without replacement.
draw_n(10, replace=False)
[Q♣, A♥, A♦, J♦, 2♦, 5♠, 8♦, J♥, 5♣, 3♠]
Example: One can draw two sets of cards each set contains four cards and compare to see which one has higher rank.
Developer install
If you want to develop nbdev_cards yourself, please use an editable installation of nbdev_cards.
git clone https://github.com/hdocmsu/nbdev_cards.git
pip install -e "nbdev_cards[dev]"
You also need to use an editable installation of nbdev, fastcore, and excnb.
Happy Coding!!!
Metadata
Release files for nbdev-cards2022 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| nbdev-cards2022-0.1.7.tar.gz | 9.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nbdev_cards2022-0.1.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 45.8 kB
Release files / nbdev-cards2022-0.1.7.tar.gz
| Download URL | nbdev-cards2022-0.1.7.tar.gz |
|---|---|
| Size | 9.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
42c060ba4bc8cecaebc818fce80592b9a64652a874a0924a1651d4ecb8ecaa97
|
|
BLAKE2b-256 checksum How to use checksums |
d025a2b9eea0cf19f9a1c5461d56aa705f799c2ee03bf599c7c42411bc309eb8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.11.3 pkginfo/1.8.2 requests/2.28.1 requests-toolbelt/0.8.0 tqdm/4.64.0 CPython/3.8.12
|
Release files / nbdev_cards2022-0.1.7-py3-none-any.whl
| Download URL | nbdev_cards2022-0.1.7-py3-none-any.whl |
|---|---|
| Size | 36.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1e4e4e0afddb24ea9702ae0db34ef4e2837fa1e282125e18ce98c1aa38feedb8
|
|
BLAKE2b-256 checksum How to use checksums |
93dd26b6afc0ba195400b19ac66a37b772d7d2fcebebca4493b63642d16c2c62
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.11.3 pkginfo/1.8.2 requests/2.28.1 requests-toolbelt/0.8.0 tqdm/4.64.0 CPython/3.8.12
|
Security for nbdev-cards2022 0.1.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.