|
| 1 | +# Kelin Ray |
1 | 2 | # Lab 4: Blackjack Advice
|
2 | 3 |
|
3 | 4 | # Let's write a python program to give basic blackjack playing advice during a game by asking the player for cards.
|
4 | 5 | # First, ask the user for three playing cards (A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, or K).
|
5 | 6 | # Then, figure out the point value of each card individually. Number cards are worth their number, all face cards are worth 10.
|
6 | 7 | # At this point, assume aces are worth 1. Use the following rules to determine the advice:
|
| 8 | +"""Add user input 3 cards, 1 deck, and Give advice based on those cards""" |
7 | 9 |
|
8 |
| -deck_one = ['A','2','3','4','5','6','7','8','9','10','J','Q','K','A','2','3','4','5','6','7','8','9','10','J','Q','K','A','2','3','4','5','6','7','8','9','10','J','Q','K','A','2','3','4','5','6','7','8','9','10','J','Q','K'] |
9 |
| -deck_two = ['A','2','3','4','5','6','7','8','9','10','J','Q','K','A','2','3','4','5','6','7','8','9','10','J','Q','K','A','2','3','4','5','6','7','8','9','10','J','Q','K','A','2','3','4','5','6','7','8','9','10','J','Q','K'] |
10 |
| -deck_three = ['A','2','3','4','5','6','7','8','9','10','J','Q','K','A','2','3','4','5','6','7','8','9','10','J','Q','K','A','2','3','4','5','6','7','8','9','10','J','Q','K','A','2','3','4','5','6','7','8','9','10','J','Q','K'] |
| 10 | +print(f"Welcome to Blackjack Advice.") |
11 | 11 |
|
12 |
| -import random |
| 12 | +first_card = input("Enter first card (A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, or K): ") |
| 13 | +second_card = input("Enter second card (A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, or K): ") |
| 14 | +third_card = input("Enter third card (A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, or K): ") |
13 | 15 |
|
14 |
| -random.shuffle(deck_one) |
15 |
| -random.shuffle(deck_two) |
16 |
| -random.shuffle(deck_three) |
| 16 | +# Deleted the random cards and now take 3 inputs for cards from the user to give advice. |
17 | 17 |
|
18 |
| -first_card = random.choice(deck_one) |
19 |
| -second_card = random.choice(deck_two) |
20 |
| -third_card = random.choice(deck_three) |
21 |
| - |
22 |
| -print(f"Welcome to Blackjack.","Your cards are:",first_card,second_card,third_card) |
| 18 | +print(f"Your cards are:",first_card,second_card,third_card) |
23 | 19 |
|
24 | 20 | if first_card == 'A':
|
25 | 21 | first_card = int('1')
|
|
68 | 64 | # Aces can be worth 11 if they won't put the total point value of both cards over 21. Remember that you can have multiple aces in a hand.
|
69 | 65 | # Try generating a list of all possible hand values by doubling the number of values in the output whenever you encounter an ace.
|
70 | 66 | # For one half, add 1, for the other, add 11. This ensures if you have multiple aces that you account for the full range of possible values.
|
| 67 | + |
0 commit comments