Skip to main content

A module to create and interact with a deck of cards object

Project description


A module to create a deck of cards object with which you can interact.


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

print("\nDeck sorted\n")

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  # string representation
card.image_path = ""  # path to an image file corresponding to the card

insert a new card into the deck

card = deck_of_cards.Card((2, 11))

shuffle the deck

print("\nDeck shuffled\n")

add a second deck of cards to the first one


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\ ............                         [100%]

----------- coverage: platform win32, python 3.5.3-final-0 -----------
Name                             Stmts   Miss  Cover
deck_of_cards\     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

deck_of_cards-0.0.10.tar.gz (5.6 kB view hashes)

Uploaded source

Built Distribution

deck_of_cards-0.0.10-py3-none-any.whl (7.0 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page