Skip to content

Commit 406196f

Browse files
committed
Merge branch 'main' into kacey-lab04-unit-blackjack
2 parents fceb0e6 + 00e8a19 commit 406196f

15 files changed

+322
-103
lines changed

1 Python/labs/04 Black Jack Advice

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Lab 4: Blackjack Advice
2+
3+
Let's write a python program to give basic blackjack playing advice during a game by asking the player for cards.
4+
First, ask the user for three playing cards (A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, or K).
5+
Then, figure out the point value of each card individually. Number cards are worth their number, all face cards are worth 10.
6+
At this point, assume aces are worth 1. Use the following rules to determine the advice:
7+
8+
Less than 17, advise to "Hit"
9+
Greater than or equal to 17, but less than 21, advise to "Stay"
10+
Exactly 21, advise "Blackjack!"
11+
Over 21, advise "Already Busted"
12+
13+
Print out the current total point value and the advice.
14+
15+
What's your first card? Q
16+
What's your second card? 2
17+
What's your third card? 3
18+
15 Hit
19+
20+
What's your first card? K
21+
What's your second card? 5
22+
What's your third card? 5
23+
20 Stay
24+
25+
What's your first card? Q
26+
What's your second card? J
27+
What's your third card? A
28+
21 Blackjack!
29+
30+
Version 2 (optional)
31+
32+
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.
33+
Try generating a list of all possible hand values by doubling the number of values in the output whenever you encounter an ace.
34+
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.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Presentation Day: November 4th, 2022
3131
| --- | ---------------------- | ------------- | --------------------- | ------------- |
3232
| 01 | Lab Average Numbers | 28 Jun | 05 Jul | 12 Jul |
3333
| 02 | Lab Unit Converter | 30 Jun | 08 Jul | 14 Jul |
34-
| 03 | Lab | 00 Jun | 00 Jun | 00 Jun |
34+
| 03 | Lab Number To Phrase | 01 Jul | 09 Jul | 15 Jul |
3535
| 04 | Lab | 00 Jun | 00 Jun | 00 Jun |
3636
| 05 | Lab | 00 Jun | 00 Jun | 00 Jun |
3737
| 06 | Lab | 00 Jun | 00 Jun | 00 Jun |

code/Andy/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ Andy
44

55
Github Username:
66
andy2124
7+

code/Andy/python.py

Whitespace-only changes.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#version 1
2+
units = {
3+
"feet": 0.3048,
4+
"meters": 1
5+
}
6+
distance = input("Enter Lenth of feet:")
7+
distance= int(distance)
8+
total = distance * units["feet"]
9+
print(f"{distance} FT is {total} Meters")
10+
11+
#version 2
12+
units_mesurments = {
13+
"feet": 0.3048,
14+
"miles": 1609.34,
15+
"meters": 1,
16+
"kilometers": 1000
17+
}
18+
19+
distance = input("what is the distance?")
20+
units = input("what are the units?:")
21+
calling = units_mesurments[units]
22+
distance = int(distance)
23+
total = distance * calling
24+
25+
print(f"{distance} {units} is {total} Meters")
26+
27+
#version 3
28+
units_mesurments = {
29+
"feet": 0.3048,
30+
"miles": 1609.34,
31+
"meters": 1,
32+
"kilometers": 1000,
33+
"yards": 0.9144,
34+
"inches": 0.0254
35+
}
36+
37+
distance = input("what is the distance?")
38+
units = input("what are the units?:")
39+
calling = units_mesurments[units]
40+
distance = int(distance)
41+
total = distance * calling
42+
43+
print(f"{distance} {units} is {total} Meters")

code/justin/lab.py

Lines changed: 0 additions & 35 deletions
This file was deleted.

code/justin/lab02_version1.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'''
2+
Justin Young
3+
Lab 02
4+
Version1
5+
'''
6+
7+
measurements = {'ft' : 0.3048, 'mi': 1609.34, 'm': 1, 'km': 1000}
8+
user_entry = input('Enter how many feet you wish to convert: ')
9+
10+
while True:
11+
try:
12+
float(user_entry)
13+
user_entry = float(user_entry)
14+
answer = user_entry * measurements['ft']
15+
break
16+
except ValueError:
17+
user_entry = input(f'Value entered is not an acceptable number try again: ')
18+
False
19+
20+
print(f'The number of meters for {user_entry} ft is {answer}')

code/justin/lab02_version2.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
'''
2+
Justin Young
3+
Lab 02
4+
Version2
5+
'''
6+
7+
measurements = {'ft' : 0.3048, 'mi': 1609.34, 'm': 1, 'km': 1000}
8+
user_distance = input(f'What is the known distance: ')
9+
while True:
10+
try:
11+
float(user_distance)
12+
user_distance = float(user_distance)
13+
break
14+
except:
15+
user_distance = input(f'Not a valid number try again: ')
16+
False
17+
print(f'{user_distance} entered')
18+
user_measurement = input(f'What is the known unit of measurement: ')
19+
while True:
20+
if user_measurement in measurements.keys():
21+
answer = user_distance * measurements[user_measurement]
22+
print(f'{user_distance} {user_measurement} is equal to {answer} meters.')
23+
break
24+
else:
25+
user_measurement = input(f'{user_measurement} is not a valid entry select from "ft", "mi", "m", "km", and try again: ')
26+
False
27+

code/justin/lab02_version3.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
'''
2+
Justin Young
3+
Lab 02
4+
Version3
5+
'''
6+
7+
measurements = {'ft' : 0.3048, 'mi': 1609.34, 'm': 1, 'km': 1000, 'yd': 0.9144, 'in': 0.0254}
8+
user_distance = input(f'What is the known distance: ')
9+
while True:
10+
try:
11+
float(user_distance)
12+
user_distance = float(user_distance)
13+
break
14+
except:
15+
user_distance = input(f'Not a valid number try again: ')
16+
False
17+
print(f'{user_distance} entered')
18+
user_measurement = input(f'What is the known unit of measurement select from "ft", "mi", "m", "km", "yd", or "in": ')
19+
while True:
20+
if user_measurement in measurements.keys():
21+
answer = user_distance * measurements[user_measurement]
22+
print(f'{user_distance} {user_measurement} is equal to {answer} meters.')
23+
break
24+
else:
25+
user_measurement = input(f'{user_measurement} is not a valid entry select from "ft", "mi", "m", "km", "yd", or "in" and try again: ')
26+
False

code/justin/lab02_version4.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
'''
2+
Justin Young
3+
Lab 02
4+
Version4
5+
'''
6+
7+
measurements = {'ft' : 0.3048, 'mi': 1609.34, 'm': 1, 'km': 1000, 'yd': 0.9144, 'in': 0.0254}
8+
user_distance = input(f'What is the known distance: ')
9+
while True:
10+
try:
11+
float(user_distance)
12+
user_distance = float(user_distance)
13+
break
14+
except:
15+
user_distance = input(f'Not a valid number try again: ')
16+
False
17+
print(f'{user_distance} entered')
18+
user_starting_measurement = input(f'What is the starting unit of measurement select from "ft", "mi", "m", "km", "yd", or "in": ')
19+
while True:
20+
if user_starting_measurement in measurements.keys():
21+
first_answer = user_distance * measurements[user_starting_measurement]
22+
break
23+
else:
24+
user_starting_measurement = input(f'{user_starting_measurement} is not a valid entry select from "ft", "mi", "m", "km", "yd", or "in" and try again: ')
25+
False
26+
user_ending_measurement = input(f'What unit are we converting to: ')
27+
while True:
28+
if user_ending_measurement in measurements.keys():
29+
second_answer = first_answer / measurements[user_ending_measurement]
30+
print(f'{user_distance} {user_starting_measurement} converts to {second_answer} {user_ending_measurement}')
31+
break
32+
else:
33+
user_ending_measurement = input(f'{user_ending_measurement} is not a valid entry select from "ft", "mi", "m", "km", "yd", or "in" and try again: ')
34+
False
35+

0 commit comments

Comments
 (0)