Skip to content

Commit 2de01f7

Browse files
deploy: 7d12b1b
0 parents  commit 2de01f7

28 files changed

Lines changed: 7678 additions & 0 deletions

.nojekyll

Whitespace-only changes.

card.html

Lines changed: 726 additions & 0 deletions
Large diffs are not rendered by default.

card.html.md

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# card–A basic playing card
2+
3+
4+
<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
5+
6+
We will be using numbers to represent playing card clubs and ranks.
7+
These are the suits:
8+
9+
``` python
10+
suits
11+
```
12+
13+
['♣️', '♦️', '❤️', '♠️']
14+
15+
For instance the suit at index `0`:
16+
17+
``` python
18+
suits[0]
19+
```
20+
21+
'♣️'
22+
23+
These are the ranks:
24+
25+
``` python
26+
ranks
27+
```
28+
29+
[None, 'A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K']
30+
31+
For instance the rank at index `1` (note that there isn’t a playing card
32+
at position `0`, since we want the ranks to match the indicies where
33+
possible):
34+
35+
``` python
36+
ranks[1]
37+
```
38+
39+
'A'
40+
41+
------------------------------------------------------------------------
42+
43+
<a
44+
href="https://github.com/moneebullah25/python_nbdev_starter/blob/main/python_nbdev_starter/card.py#L17"
45+
target="_blank" style="float:right; font-size:smaller">source</a>
46+
47+
### Card
48+
49+
``` python
50+
51+
def Card(
52+
suit:int, # An index into `suits`
53+
rank:int, # An index into `ranks`
54+
):
55+
56+
```
57+
58+
*A playing card*
59+
60+
Here’s an example of creating and displaying a card:
61+
62+
``` python
63+
c = Card(suit=1, rank=3)
64+
c
65+
```
66+
67+
3♦️
68+
69+
## Comparison operators
70+
71+
Equality, less than, and greater than work on the rank and suit indices.
72+
73+
------------------------------------------------------------------------
74+
75+
<a
76+
href="https://github.com/moneebullah25/python_nbdev_starter/blob/main/python_nbdev_starter/card.py#L45"
77+
target="_blank" style="float:right; font-size:smaller">source</a>
78+
79+
### Card.\_\_gt\_\_
80+
81+
``` python
82+
83+
def __gt__(
84+
a:Card
85+
):
86+
87+
```
88+
89+
*Return self\>value.*
90+
91+
------------------------------------------------------------------------
92+
93+
<a
94+
href="https://github.com/moneebullah25/python_nbdev_starter/blob/main/python_nbdev_starter/card.py#L40"
95+
target="_blank" style="float:right; font-size:smaller">source</a>
96+
97+
### Card.\_\_lt\_\_
98+
99+
``` python
100+
101+
def __lt__(
102+
a:Card
103+
):
104+
105+
```
106+
107+
*Return self\<value.*
108+
109+
------------------------------------------------------------------------
110+
111+
<a
112+
href="https://github.com/moneebullah25/python_nbdev_starter/blob/main/python_nbdev_starter/card.py#L35"
113+
target="_blank" style="float:right; font-size:smaller">source</a>
114+
115+
### Card.\_\_eq\_\_
116+
117+
``` python
118+
119+
def __eq__(
120+
a:Card
121+
):
122+
123+
```
124+
125+
*Return self==value.*
126+
127+
For instance, here’s a test of equality…
128+
129+
``` python
130+
test_eq(Card(suit=1, rank=3), Card(suit=1, rank=3))
131+
```
132+
133+
…and a test of `<`
134+
135+
``` python
136+
assert Card(suit=1, rank=3)<Card(suit=2, rank=3)
137+
```
138+
139+
…and finally of `>`:
140+
141+
``` python
142+
assert Card(suit=3, rank=3)>Card(suit=2, rank=3)
143+
assert not Card(suit=1, rank=3)>Card(suit=2, rank=3)
144+
```

0 commit comments

Comments
 (0)