Skip to content

Commit f3de061

Browse files
committed
Cleaned up branch and renamed to lab03-number-to-phrases
2 parents e77d8c4 + 22169dd commit f3de061

32 files changed

+1331
-180
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Ignore any user's VSCode workspace file
22
*code-workspace
3+
.VSCode
34

45
# Created by https://www.toptal.com/developers/gitignore/api/python,windows,macos
56
# Edit at https://www.toptal.com/developers/gitignore?templates=python,windows,macos
Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,45 @@
1-
Lab 01: Average Numbers
1+
# Lab 01: Average Numbers
2+
3+
## Version 1
24

35
We're going to average a list of numbers. Start with the following list, iterate through it, keeping a 'running sum', then divide that sum by the number of elements in that list. Remember len will give you the length of a list.
46

57
The code below shows how to loop through an array, and prints the elements one at a time.
68

9+
```python
710
nums = [5, 0, 8, 3, 4, 1, 6]
11+
```
12+
13+
### loop over the elements
814

9-
# loop over the elements
15+
```python
1016
for num in nums:
1117
print(num)
18+
```
19+
20+
### loop over the indices
1221

13-
# loop over the indices
22+
```python
1423
for i in range(len(nums)):
1524
print(nums[i])
25+
```
1626

17-
Version 2
27+
## Version 2
1828

1929
Ask the user to enter the numbers one at a time, putting them into a list. If the user enters 'done', then calculate and display the average. The following code demonstrates how to add an element to the end of a list.
2030

31+
```python
2132
nums = []
2233
nums.append(5)
2334
print(nums)
35+
```
2436

2537
Below is an example input/output:
2638

39+
```log
2740
> enter a number, or 'done': 5
2841
> enter a number, or 'done': 3
2942
> enter a number, or 'done': 4
3043
> enter a number, or 'done': done
31-
average: 4
44+
> average: 4
45+
```

1 Python/labs/03 Number To Phrases

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Lab 3: Number to Phrase
2+
3+
## Version 1
4+
5+
- Convert a given number into its english representation.
6+
7+
### For example: 67 becomes 'sixty-seven'.
8+
9+
- Handle numbers from 0-99
10+
11+
### Hint: you can use modulus to extract the ones and tens digit
12+
13+
```python
14+
x = 67
15+
tens_digit = x//10
16+
ones_digit = x%10
17+
```
18+
19+
### Hint 2: use the digit as an index for a list of strings OR as a key for a dict of digit:phrase pairs.
20+
21+
## Version 2
22+
23+
- Handle numbers from 100-999.
24+
25+
## Version 3 (optional)
26+
27+
- Convert a number to roman numerals.
28+
29+
## Version 4 (optional)
30+
31+
- Convert a time given in hours and minutes to a phrase.

1 Python/labs/04 Black Jack Advice

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

1 Python/labs/05 Pick6.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Pick6
2+
3+
Have the computer play pick6 many times and determine net balance.
4+
5+
Initially the program will pick 6 random numbers as the 'winner'. Then try playing pick6 100,000 times, with the ticket cost and payoff below.
6+
7+
A ticket contains 6 numbers, 1 to 99, and the number of matches between the ticket and the winning numbers determines the payoff. Order matters, if the winning numbers are `[5, 10]` and your ticket numbers are `[10, 5]` you have **0** matches. If the winning numbers are `[5, 10, 2]` and your ticket numbers are `[10, 5, 2]`, you have **1** match. Calculate your net winnings (the sum of all expenses and earnings).
8+
9+
- a ticket costs $2
10+
- if 1 number matches, you win $4
11+
- if 2 numbers match, you win $7
12+
- if 3 numbers match, you win $100
13+
- if 4 numbers match, you win $50,000
14+
- if 5 numbers match, you win $1,000,000
15+
- if 6 numbers match, you win $25,000,000
16+
17+
Write the following functions and use them in the code:
18+
19+
- `pick6()`: Generate a list of 6 random numbers, which can then be used for both the winning numbers and tickets. Return the list
20+
- `num_matches(winning, ticket)`: Return the number of matches between the winning numbers and the ticket.
21+
22+
## Steps
23+
24+
1. Generate a list of 6 random numbers representing the winning tickets
25+
2. Start your balance at 0
26+
3. Loop 100,000 times, for each loop:
27+
4. Generate a list of 6 random numbers representing the ticket
28+
5. Subtract 2 from your balance (you bought a ticket)
29+
6. Find how many numbers match
30+
7. Add to your balance the winnings from your matches
31+
8. After the loop, print the final balance
32+
33+
## Version 2
34+
35+
The ROI (return on investment) is defined as `(earnings - expenses)/expenses`. Calculate your ROI, print it out along with your earnings and expenses.

1 Python/labs/06 Make Change

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Lab 06: Make Change
2+
3+
Let's convert a dollar amount into a number of coins. The input will be the total amount, the output will be the number of quarters, dimes, nickles, and pennies.
4+
Always break the total into the highest coin value first, resulting in the fewest amount of coins. For this, you'll have to use floor division //,
5+
which throws away the remainder. 10/3 is 3.333333, 10//3 is 3.
6+
7+
Welcome to the Change Maker 5000 (tm)
8+
Enter a dollar amount: 1.36
9+
5 quarters, 1 dime, and 1 penny
10+
Would you like make more change? yes
11+
Enter a dollar amount: 0.67
12+
2 quarters, 1 dime, 1 nickel, 2 pennies
13+
Would you like make more change? no
14+
Have a good day!
15+
16+
Version 2 (optional)
17+
18+
Instead of hard-coding the coins, store them in a list of tuples. This way you can make custom coins.
19+
20+
coins = [
21+
('half-dollar', 50),
22+
('quarter', 25),
23+
('dime', 10),
24+
('nickel', 5),
25+
('penny', 1)
26+
]

README.md

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,44 @@
1-
# class_HB2
2-
## 2022-06-22 Full-Stack Python/JavaScript Evening Class
1+
# Class_HB2
32

3+
## 2022-06-22 Full-Stack Python/JavaScript Evening Class
44

55
Repo for the PDX Code Guild Python Full Stack evening course starting 06/27/2022
66

7-
Class is held from **July 27th, 2022 to November 4th, 2022**
8-
M-F 6:00 pm – 9:36 pm pst
7+
Class is held from **June 27th, 2022 to November 4th, 2022**
8+
M-F 6:00 pm – 9:36 pm PT
99

1010
### Holidays
1111

12-
- July 4th 21st (Independence Day)
12+
- ~~July 4th 21st (Independence Day)~~
1313
- September 5th (Labor Day)
1414

1515
### Staff
1616

1717
- Irron Williams, Instructor
18-
19-
20-
- Dustin Olsen, TA
18+
2119
- Bruce Stull, TA
2220

23-
## Capstone Dates:
21+
## Capstone Dates
2422

2523
Capstone proposal due: Oct 10th, 2022
26-
Presentation Day: November 4th, 2022
24+
Presentation Day: November 4th, 2022
2725

2826
## Python Labs Assigned:
2927

30-
| Lab | Name | Date Assigned | Due By Start Of Class | Hard Due Date |
31-
| --- | ---------------------- | ------------- | --------------------- | ------------- |
32-
| 01 | Lab Average Numbers | 28 Jun | 05 Jul | 12 Jul |
33-
| 02 | Lab Unit Converter | 30 Jun | 08 Jul | 14 Jul |
34-
| 03 | Lab Number To Phrase | 01 Jul | 09 Jul | 15 Jul |
35-
| 04 | Lab Black Jack Advice | 06 Jul | 13 Jul | 20 Jul |
36-
| 05 | Lab Pick6 | 07 Jul | 14 Jul | 21 Jul |
37-
| 06 | Lab | 00 Jun | 00 Jun | 00 Jun |
38-
| 07 | Lab | 00 Jun | 00 Jun | 00 Jun |
39-
| 08 | Lab | 00 Jun | 00 Jun | 00 Jun |
40-
| 09 | Lab | 00 Jun | 00 Jun | 00 Jun |
41-
| 12 | Lab | 00 Jun | 00 Jun | 00 Jun |
42-
| 14 | Lab | 00 Jun | 00 Jun | 00 Jun |
43-
| 15 | Lab | 00 Jun | 00 Jun | 00 Jun |
44-
45-
28+
| Lab | Name | Date Assigned | Due By Start Of Class | Hard Due Date |
29+
| --- | ------------------------------------------------------------------ | ------------- | --------------------- | ------------- |
30+
| 01 | [Average Numbers](1%20Python/labs/01%20Average%20Numbers.md) | 28 Jun | 05 Jul | 12 Jul |
31+
| 02 | [Unit Converter](1%20Python/labs/02%20Unit%20Converter.md) | 30 Jun | 08 Jul | 14 Jul |
32+
| 03 | [Number To Phrase](1%20Python/labs/03%20Number%20To%20Phrases.md) | 01 Jul | 09 Jul | 15 Jul |
33+
| 04 | [Black Jack Advice](1%20Python/labs/04%20Black%20Jack%20Advice.md) | 06 Jul | 13 Jul | 20 Jul |
34+
| 05 | [Pick 6](1%20Python/labs/05%20Pick6.md) | 07 Jul | 14 Jul | 21 Jul |
35+
| 06 | [Make Change](1%20Python/labs/06%20Make%20Change) | 12 Jul | 19 Jul | 26 Jul |
36+
| 07 | Lab | 00 Jun | 00 Jun | 00 Jun |
37+
| 08 | Lab | 00 Jun | 00 Jun | 00 Jun |
38+
| 09 | Lab | 00 Jun | 00 Jun | 00 Jun |
39+
| 12 | Lab | 00 Jun | 00 Jun | 00 Jun |
40+
| 14 | Lab | 00 Jun | 00 Jun | 00 Jun |
41+
| 15 | Lab | 00 Jun | 00 Jun | 00 Jun |
4642

4743
## Getting Unstuck
4844

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# # Version 1
2+
# nums = [5, 0, 8, 3, 4, 1, 6]
3+
4+
# total = 0
5+
6+
# for num in nums:
7+
# total = total + num
8+
9+
# average = total/(len(nums))
10+
# print(average)
11+
12+
13+
# for i in range(len(nums)):
14+
# print(nums[i])
15+
16+
# Version 2
17+
18+
19+
20+
nums = [] #place holder
21+
sum = 0 # place to help when adding the num together and help get the average
22+
23+
while True: #while statement to get all the numbers being put by the user
24+
user= input(' Please enter a number or done when finished: ')
25+
if user == 'done':
26+
break
27+
nums.append(int(user)) #strings dont add together for numbers, .append adding all the numbers in a list and the int making them into an integer.
28+
# print(nums)
29+
30+
for num in nums: #for statement helping me get the nums value of all the inputs and calling out single ones
31+
sum += num #where it calls the sigle ones and adds them together
32+
average = sum/ len(nums) #the len is getting the length of numbers so getting how many there is and the sum is getting the value of all the ones being put together and dividing them to get the average
33+
34+
print (f" Your total average is {round(average)} ") #round removes the decimal and has to be within the curly bracket to have the function work

0 commit comments

Comments
 (0)