@@ -19,7 +19,8 @@ def value_of_card(card) -> int:
1919 """
2020 if card in 'JKQ' :
2121 return 10
22- elif card == 'A' :
22+
23+ if card == 'A' :
2324 return 1
2425
2526 return int (card )
@@ -29,16 +30,19 @@ def higher_card(card_one, card_two) -> str | tuple[str, str]:
2930 """
3031 Determine which card has a higher value in the hand.
3132
32- :param card_one, card_two: str - cards dealt in hand. See below for values.
33- :return: str or tuple - resulting Tuple contains both cards if they are of equal value.
33+ :param card_one: str - cards dealt in hand. See below for values.
34+ :param card_two: str - cards dealt in hand. See below for values.
35+ :return: str or tuple - resulting Tuple contains both cards if
36+ they are of equal value.
3437
3538 1. 'J', 'Q', or 'K' (otherwise known as "face cards") = 10
3639 2. 'A' (ace card) = 1
3740 3. '2' - '10' = numerical value.
3841 """
3942 if value_of_card (card_one ) == value_of_card (card_two ):
4043 return card_one , card_two
41- elif value_of_card (card_one ) > value_of_card (card_two ):
44+
45+ if value_of_card (card_one ) > value_of_card (card_two ):
4246 return card_one
4347
4448 return card_two
@@ -56,11 +60,14 @@ def value_of_ace(card_one, card_two) -> int:
5660 3. '2' - '10' = numerical value.
5761 """
5862 total : int = value_of_card (card_one ) + value_of_card (card_two )
59- # Hint: if we already have an ace in hand, then the value for the upcoming ace would be 1.
63+ # Hint: if we already have an ace in hand, then the value for
64+ # the upcoming ace would be 1.
6065 if card_one == 'A' or card_two == 'A' :
6166 return 1
62- # The value of the hand with the ace needs to be as high as possible without going over 21.
63- elif 21 - total >= 11 :
67+ # The value of the hand with the ace needs to be as high as
68+ # possible without going over 21.
69+
70+ if 21 - total >= 11 :
6471 return 11
6572
6673 return 1
@@ -70,7 +77,10 @@ def is_blackjack(card_one, card_two) -> bool:
7077 """
7178 Determine if the hand is a 'natural' or 'blackjack'.
7279
73- :param card_one, card_two: str - card dealt. See below for values.
80+ :param card_one: card dealt. See below for values.
81+ :type card_one: str
82+ :param card_two: card dealt. See below for values.
83+ :type card_two: str
7484 :return: bool - is the hand is a blackjack (two cards worth 21).
7585
7686 1. 'J', 'Q', or 'K' (otherwise known as "face cards") = 10
@@ -81,7 +91,8 @@ def is_blackjack(card_one, card_two) -> bool:
8191 # as their first two cards, then the player has a score of 21.
8292 if card_one == 'A' and card_two in ('J' , 'Q' , 'K' , '10' ):
8393 return True
84- elif card_two == 'A' and card_one in ('J' , 'Q' , 'K' , '10' ):
94+
95+ if card_two == 'A' and card_one in ('J' , 'Q' , 'K' , '10' ):
8596 return True
8697
8798 return False
@@ -91,8 +102,10 @@ def can_split_pairs(card_one, card_two) -> bool:
91102 """
92103 Determine if a player can split their hand into two hands.
93104
94- :param card_one, card_two: str - cards dealt.
95- :return: bool - can the hand be split into two pairs? (i.e. cards are of the same value).
105+ :param card_one: str - cards dealt.
106+ :param card_two: str - cards dealt.
107+ :return: bool - can the hand be split into two pairs?
108+ (i.e. cards are of the same value).
96109 """
97110 if value_of_card (card_one ) == value_of_card (card_two ):
98111 return True
@@ -104,7 +117,9 @@ def can_double_down(card_one, card_two) -> bool:
104117 """
105118 Determine if a blackjack player can place a double down bet.
106119
107- :param card_one, card_two: str - first and second cards in hand.
108- :return: bool - can the hand can be doubled down? (i.e. totals 9, 10 or 11 points).
120+ :param card_one: str - first and second cards in hand.
121+ :param card_two: str - first and second cards in hand.
122+ :return: bool - can the hand can be doubled down?
123+ (i.e. totals 9, 10 or 11 points).
109124 """
110125 return 9 <= value_of_card (card_one ) + value_of_card (card_two ) <= 11
0 commit comments