|
1 | 1 | # General |
2 | 2 |
|
3 | | -- [The Python Comparisons Tutorial][the python comparisons tutorial] and [Python comparisons examples][python comparisons examples] can be a great introduction. |
| 3 | +[The Python comparisons tutorial][python comparisons tutorial] and [Python comparisons examples][python comparisons examples] are a great introduction covering the content of this exercise. |
4 | 4 |
|
5 | | -## 1. Calculate the number of card |
| 5 | +## 1. Calculate the value of a card |
6 | 6 |
|
7 | | -- You can use the [equality comparison operator][equality comparison operator] to get the number of the card. |
| 7 | +- You can use the equality comparison operator `==` to determine specific cards, e.g. `card == 'J'`. |
| 8 | +- You can use the [`int` constructor][int constructor] to get an integer number from an integer literal, e.g. `int(card)`. |
8 | 9 |
|
9 | | -## 2. Calculate the number of Ace |
| 10 | +## 2. Calculate the value of an ace |
10 | 11 |
|
11 | | -- You can use the [order comparisons operator][order comparisons operator]to decide the value of ace without the sum of hand exceeding 21. |
| 12 | +- You can use the order comparison operator `>` to decide the appropriate course of action, e.g. `hand_value + 11 > 21`. |
12 | 13 |
|
13 | | -## 3. Judge Blackjack |
| 14 | +## 3. Determine Blackjack |
14 | 15 |
|
15 | | -- You can use the [membership test operations][membership test operations] in `if` or `elif` syntax to find black-jack from the first two cards in your hand. |
| 16 | +- You can use the [`if`/`elif`/`else` syntax][if syntax] to handle different combinations of cards. |
| 17 | +- You can reuse the already implemented `value_of_card` function. |
16 | 18 |
|
17 | | -[the python comparisons tutorial]: https://docs.python.org/3/reference/expressions.html#comparisons |
| 19 | +## 4. Splitting pairs |
| 20 | + |
| 21 | +- You can handle the `A` case (when at least one of the cards in an ace) separately. |
| 22 | + |
| 23 | +## 5. Doubling down |
| 24 | + |
| 25 | +- You can chain comparison operators, e.g. `9 <= hand_value <= 11`. |
| 26 | +- You can use the [conditional expression][conditional expression] (sometimes called a "ternary operator") |
| 27 | +to shorten simple `if`/`else` statements, e.g. `1 if card == 'A' else value_of_card(card)`. |
| 28 | + |
| 29 | +[python comparisons tutorial]: https://docs.python.org/3/reference/expressions.html#comparisons |
18 | 30 | [python comparisons examples]: https://www.tutorialspoint.com/python/comparison_operators_example.htm |
19 | | -[equality comparison operator]: https://docs.python.org/3/reference/expressions.html#comparisons |
20 | | -[order comparisons operator]: https://docs.python.org/3/reference/expressions.html#comparisons |
21 | | -[membership test operations]: https://docs.python.org/3/reference/expressions.html#comparisons |
| 31 | +[int constructor]: https://docs.python.org/3/library/functions.html#int |
| 32 | +[if syntax]: https://docs.python.org/3/tutorial/controlflow.html#if-statements |
| 33 | +[conditional expression]: https://docs.python.org/3/reference/expressions.html#conditional-expressions |
0 commit comments