# card – A basic playing card


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

``` python
print(f"Spades: {spades}, Hearts: {hearts}, Diamonds: {diamonds}, Clubs: {clubs}")
```

    Spades: ♠, Hearts: ♥, Diamonds: ♦, Clubs: ♣

``` python
```

    ERROR:root:No traceback has been produced, nothing to debug.

We will use numbers to represent playing cards clubs anbf ranks. These
are the ranks:

``` python
suits
```

    ['♣', '♦', '♥', '♠']

For instance, the suit at number 0:

``` python
suits[0]
```

    '♣'

These are the ranks:

``` python
ranks
```

    [None, 'A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K']

For instance, the rank at index ‘1’ (note that there isn’t a card at
position ‘0’ since we want the ranks to match the indeces where
possible):

``` python
ranks[1]
```

    'A'

``` python
Card(1,3)
```

    3, ♦

## Comparisson operators

------------------------------------------------------------------------

<a
href="https://github.com/rdned/nbdev_cards3.14/blob/main/nbdev_cards/card.py#L39"
target="_blank" style="float:right; font-size:smaller">source</a>

### Card.\_\_eq\_\_

>  Card.__eq__ (a:__main__.Card)

*Return self==value.*

For instance, here is a tet of equallity…

``` python
test_eq(Card(suit=1, rank=3), Card(suit=1, rank=3) )
```

------------------------------------------------------------------------

<a
href="https://github.com/rdned/nbdev_cards3.14/blob/main/nbdev_cards/card.py#L44"
target="_blank" style="float:right; font-size:smaller">source</a>

### Card.\_\_lt\_\_

>  Card.__lt__ (a:__main__.Card)

*Return self\<value.*

and a test of `<` …

``` python
assert Card(suit=1, rank=3) < Card(suit=2, rank=3)
```

------------------------------------------------------------------------

<a
href="https://github.com/rdned/nbdev_cards3.14/blob/main/nbdev_cards/card.py#L49"
target="_blank" style="float:right; font-size:smaller">source</a>

### Card.\_\_gt\_\_

>  Card.__gt__ (a:__main__.Card)

*Return self\>value.*

… and finaly of `>`:

``` python
assert Card(suit=3, rank=3) > Card(suit=2, rank=3)
assert not Card(suit=1, rank=3) > Card(suit=2, rank=3)
```

Here is an example of creating and displaying a card

``` python
c = Card(suit=1, rank=3)
```

``` python
c
```

    3, ♦

``` python
print(c)
```

    3, ♦

------------------------------------------------------------------------

<a
href="https://github.com/rdned/nbdev_cards3.14/blob/main/nbdev_cards/card.py#L22"
target="_blank" style="float:right; font-size:smaller">source</a>

### Card

>  Card (suit:int, rank:int)

*A playing card*

<table>
<thead>
<tr>
<th></th>
<th><strong>Type</strong></th>
<th><strong>Details</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>suit</td>
<td>int</td>
<td>An index into suits</td>
</tr>
<tr>
<td>rank</td>
<td>int</td>
<td>An index into ranks</td>
</tr>
</tbody>
</table>

Equality, less than, and greater than work on the rank and siuit
indices:

``` python
c = Card(suit=1, rank=3)
```
