A module to create and interact with a deck of cards object
Project description
deck_of_cards
A module to create a deck of cards object with which you can interact.
Documentation
https://deck-of-cards.readthedocs.io/en/latest/
Example usage
import the module
from deck_of_cards import deck_of_cards
create an instance of DeckOfCards
deck_obj = deck_of_cards.DeckOfCards()
add jokers
deck_obj.add_jokers()
sort the deck by card value
deck_obj.order_deck()
print("\nDeck sorted\n")
deck_obj.print_deck()
give out a random card
card = deck_obj.give_random_card()
card objects have the following attributes
card.suit # 0=spades, 1=hearts, 2=diamonds, 3=clubs, 4=joker
card.rank # 1=Ace, 11=Jack, 12=Queen, 13=King, 14=B&W Joker, 15=Color Joker
card.value # defaults: same as rank
card.name # string representation
card.image_path = "" # path to an image file corresponding to the card
insert a new card into the deck
print(len(deck_obj.deck))
card = deck_of_cards.Card((2, 11))
print(card.name)
deck_obj.take_card(card)
print(len(deck_obj.deck))
shuffle the deck
deck_obj.shuffle_deck()
print("\nDeck shuffled\n")
deck_obj.print_deck()
add a second deck of cards to the first one
print(len(deck_obj.deck))
deck_obj.add_deck()
print(len(deck_obj.deck))
Test coverage
============================= test session starts =============================
platform win32 -- Python 3.5.3, pytest-3.6.2, py-1.5.3, pluggy-0.6.0
rootdir: C:\Users\Smoky05\PycharmProjects\deck_of_cards, inifile:
plugins: cov-2.5.1
collected 12 items
deck_of_cards\test_deck_of_cards.py ............ [100%]
----------- coverage: platform win32, python 3.5.3-final-0 -----------
Name Stmts Miss Cover
----------------------------------------------------
deck_of_cards\deck_of_cards.py 131 29 78%
========================== 12 passed in 0.15 seconds ==========================
Project details
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_of_cards-0.0.10.tar.gz.
File metadata
- Download URL: deck_of_cards-0.0.10.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f66cea62d87c650a602f1f1aa78444b0ea5e54dc0c36f21771dc47ad933942c9
|
|
| MD5 |
c1562b117b135f93a174d1dca9f4e663
|
|
| BLAKE2b-256 |
afb4efbe681c505308bd1ea9331ffadc32a8468a9a8ce1c3717adbc851a43b6a
|
File details
Details for the file deck_of_cards-0.0.10-py3-none-any.whl.
File metadata
- Download URL: deck_of_cards-0.0.10-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76bf77c1b752c337bcb6dd2350c9d249fc0ed8ccf07a4255049514e9fd166635
|
|
| MD5 |
6353c1d44c07d81dc8b3ae46ad16858b
|
|
| BLAKE2b-256 |
77e63dcb4a79adccf906e34ec0fc2564ac06a54a399fbc69508f39733a1c29a8
|