Card

Define a card in a deck of cards

Card

 Card (suit=0, rank=2)

Represents a standard playing card.

Creating Cards

Card is a class that represents a single card in a deck of cards. We can create cards like this:

c = Card(suit=1, rank=3)
c
3♦️

In these docs we’ll generally show the expected output from our code like so:

test_eq(str(c), '3♦️')
c2 = Card(suit=2, rank=11)
test_eq(str(c2), 'J❤️')
Tip

These test_eq statements are not just documentation, they are also unit tests! These cells will get tested automatically with continous integration. You can also run tests locally with the command nbdev_test. If you do not want to show a test in your docs, you can choose to hide cells with the #|hide directive.

Comparing Cards

You can also compare cards like so:

test_eq(c2 > c, True)