Deck of Cards Documentation
Release 0.0.1
Suhas Gaddam
Jul 07, 2017
Contents
1
2
deck_of_cards package
1.1 Module contents . . . . . . . . . . .
1.2 Submodules . . . . . . . . . . . . .
1.2.1
deck_of_cards.card module .
1.2.2
deck_of_cards.deck module
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
3
3
3
3
5
Indices and tables
7
Python Module Index
9
i
ii
Deck of Cards Documentation, Release 0.0.1
Contents:
Contents
1
Deck of Cards Documentation, Release 0.0.1
2
Contents
CHAPTER
1
deck_of_cards package
Module contents
A Python Implementation Of A Deck of Cards
Submodules
deck_of_cards.card module
This module provides the Card object. This module also has 5 constant attributes that help validate or
string format the Card object: POSSIBLE_SUIT, POSSIBLE_RANK, , JOKER_SUIT, JOKER_RANK, and
RANK_TRANSLATION
class deck_of_cards.card.Card(rank, suit)
Bases: object
A Card object
Parameters
• rank (int) – a rank in POSSIBLE_RANK or JOKER_RANK
• suit (str) – a case-independent string in POSSIBLE_SUIT or JOKER_SUIT
Raises ValueError
__eq__(other)
Override equality method
Returns True if two objects are cards and have the same _rank and _suit
Return type bool
__ne__(other)
Override inequality method
3
Deck of Cards Documentation, Release 0.0.1
Returns not __eq__
Return type bool
__repr__()
This method returns an unambigious string representation of the card object
Returns unambigious string represenation of card object
Return type str
__str__()
This method returns a nice string representation of the card object
useful in printing card object as “%s”
Returns human readable string represenation of card object
Return type str
_rank = None
Holds an integer which represents the card rank
_suit = None
Holds the suit as a lowercase string
_translate_rank()
This is a hidden method that changes the card rank to a human-readable string. It also returns the title case
of the string if possible.
‘Ace’ for 1
‘Joker’ for joker
Returns human-readable string for face cards or card rank
Return type str
get_rank()
Returns _rank
Return type int
get_suit()
Returns _suit
Return type str
is_joker()
Returns True if joker
Return type bool
deck_of_cards.card.JOKER_RANK = 0
a number representing the Joker’s rank
deck_of_cards.card.JOKER_SUIT = ‘joker’
a string representing the Joker’s suit
deck_of_cards.card.POSSIBLE_RANK = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
an array with the possible ranks
deck_of_cards.card.POSSIBLE_SUIT = [’hearts’, ‘diamonds’, ‘spades’, ‘clubs’]
an array with all the possible suit strings
4
Chapter 1. deck_of_cards package
Deck of Cards Documentation, Release 0.0.1
deck_of_cards.card.RANK_TRANSLATION = {1: ‘ace’, 11: ‘jack’, 12: ‘queen’, 13: ‘king’}
a dictionary which translates the special face cards to strings
deck_of_cards.deck module
This module provides the Deck object
class deck_of_cards.deck.Deck(with_jokers=True)
Bases: object
A Deck object
A new deck starts out ordered.
If jokers are included, contains (2 + 4 * 13) deck_of_cards.card.Card objects
If no jokers are included, contains (4 * 13) deck_of_cards.card.Card objects
Parameters with_jokers (bool) – include jokers if True
__repr__()
Returns unambigious string represenation of deck object
Return type str
__str__()
Returns human readable string represenation of deck object
Return type str
_cards = []
an array of unused deck_of_cards.card.Card objects that are waiting to be dealt
_discarded_cards = []
an array of discarded deck_of_cards.card.Card objects
_in_play_cards = []
an array of deck_of_cards.card.Card objects that have been dealt
_with_jokers = True
a boolean to represent if jokers exist in deck
check_deck()
Check to make sure all the cards are accounted
Returns True if all cards are accounted
Return type bool
deal()
Deals a single deck_of_cards.card.Card from _cards
Raises an IndexError when _cards is empty
Returns a single deck_of_cards.card.Card
Return type deck_of_cards.card.Card
Raises IndexError
discard(cards)
Remove cards from the _in_play_cards array and add them to _discarded_cards array
Raises a ValueError when trying to discard a card that does not exist in _in_play_cards.
1.2. Submodules
5
Deck of Cards Documentation, Release 0.0.1
Parameters cards (array) – an array of deck_of_cards.card.Card objects or a single deck_of_cards.card.Card
Raises ValueError
is_empty()
This method returns true if the deck(_cards) is empty
Returns True if deck is empty
Return type bool
shuffle()
Shuffle the unused set of cards in _cards
deck_of_cards.deck.LOGGER = <logging.Logger object>
a logger object
6
Chapter 1. deck_of_cards package
CHAPTER
2
Indices and tables
• genindex
• modindex
• search
7
Deck of Cards Documentation, Release 0.0.1
8
Chapter 2. Indices and tables
Python Module Index
d
deck_of_cards, 3
deck_of_cards.card, 3
deck_of_cards.deck, 5
9
Deck of Cards Documentation, Release 0.0.1
10
Python Module Index
Index
Symbols
L
__eq__() (deck_of_cards.card.Card method), 3
__ne__() (deck_of_cards.card.Card method), 3
__repr__() (deck_of_cards.card.Card method), 4
__repr__() (deck_of_cards.deck.Deck method), 5
__str__() (deck_of_cards.card.Card method), 4
__str__() (deck_of_cards.deck.Deck method), 5
_cards (deck_of_cards.deck.Deck attribute), 5
_discarded_cards (deck_of_cards.deck.Deck attribute), 5
_in_play_cards (deck_of_cards.deck.Deck attribute), 5
_rank (deck_of_cards.card.Card attribute), 4
_suit (deck_of_cards.card.Card attribute), 4
_translate_rank() (deck_of_cards.card.Card method), 4
_with_jokers (deck_of_cards.deck.Deck attribute), 5
LOGGER (in module deck_of_cards.deck), 6
P
POSSIBLE_RANK (in module deck_of_cards.card), 4
POSSIBLE_SUIT (in module deck_of_cards.card), 4
R
RANK_TRANSLATION
deck_of_cards.card), 4
(in
module
S
shuffle() (deck_of_cards.deck.Deck method), 6
C
Card (class in deck_of_cards.card), 3
check_deck() (deck_of_cards.deck.Deck method), 5
D
deal() (deck_of_cards.deck.Deck method), 5
Deck (class in deck_of_cards.deck), 5
deck_of_cards (module), 3
deck_of_cards.card (module), 3
deck_of_cards.deck (module), 5
discard() (deck_of_cards.deck.Deck method), 5
G
get_rank() (deck_of_cards.card.Card method), 4
get_suit() (deck_of_cards.card.Card method), 4
I
is_empty() (deck_of_cards.deck.Deck method), 6
is_joker() (deck_of_cards.card.Card method), 4
J
JOKER_RANK (in module deck_of_cards.card), 4
JOKER_SUIT (in module deck_of_cards.card), 4
11
© Copyright 2026 Paperzz