Playing Cards

class Deck[source]


Represents a deck of cards. Attributes: cards: list of Card objects.

A Deck of cards is a collection of Card objects:

deck = Deck()
assert isinstance(deck.pop_card(), Card)



Removes a card from the deck or raises exception if it is not there.

card: Card

If we remove a card from the Deck we can verify that it no longer exists:

card23 = Card(2, 3)

assert card23 not in

However, another card that we haven't removed, such as the 10 of hearts will still be in the Deck of cards because we haven't removed it:

c = Card(2,10)
assert c in
10 of Hearts