Skip to content

Commit 80e7fc9

Browse files
committed
try fix merge conflict
2 parents 04b3ec2 + 0da7ec7 commit 80e7fc9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+3368
-131
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

0 General/10 GitHub Pull Request.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
1. Verify the 'Comparing changes' is set to compare your lab branch with 'base: main':
1616
![04_verify_comparing_changes](https://user-images.githubusercontent.com/47562501/175929257-e582d9ba-61bc-4b02-aa93-eab9e8d1ead3.png)
1717

18+
1. Verify that the only file changes included in Pull Request are for the lab designated in branch name:
19+
![04 5_verify_only_appropriate_labs_have_changed](https://user-images.githubusercontent.com/47562501/178146015-f3bb66b1-a19d-4fc8-b612-0054d408aa64.png)
20+
1821
1. Click 'Create pull request' button:
1922
![05_click_create_pull_request](https://user-images.githubusercontent.com/47562501/175929274-627d1818-fe98-4c56-8715-8f7407807f01.png)
2023

0 General/11 Git Lab Workflow.md

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Git Lab Workflow
22

3-
## The below is an example of workflow for creating branches for each new lab.
3+
## Create a new branch for each new lab.
44

55
* Replace the `<new-branch-name>` items below with your appropriate formed `<studentdirectoryname-labnumber-lab-name>` branch name.
66
* An example `<new-branch-name>` would be `bruce-lab01-python-exercise`
@@ -22,8 +22,17 @@
2222

2323
1. Do some code changes.
2424

25-
1. Add all the changes made to git tracking (or add only `<filename>` or `<directoryname>` changes):
26-
`git add -A`
25+
1. Use `git status` to view what files and directories have been changed:
26+
`git status`
27+
28+
1. Use whichever or these four options is appropriate to add the necessary files to git tracking:
29+
`git add .`
30+
`git add <filepath>`
31+
`git add <directorypath>`
32+
`git add -A`
33+
34+
1. Use `git status` to view what files and directories will be added to the commit:
35+
`git status`
2736

2837
1. Commit the changes made to the branch:
2938
`git commit -m <commit message>`
@@ -33,8 +42,17 @@
3342

3443
1. Do some more code changes.
3544

36-
1. Add all the changes made to git tracking:
37-
`git add -A`
45+
1. Use `git status` to view what files and directories have been changed:
46+
`git status`
47+
48+
1. Use whichever or these four options is appropriate to add the necessary files to git tracking:
49+
`git add .`
50+
`git add <filepath>`
51+
`git add <directorypath>`
52+
`git add -A`
53+
54+
1. Use `git status` to view what files and directories will be added to the commit:
55+
`git status`
3856

3957
1. Commit the changes made to the branch:
4058
`git commit -m <commit message>`
@@ -50,7 +68,7 @@
5068

5169
1. Repeat process for new labs.
5270

53-
## Use the following to switch between multiple in-process lab branches.
71+
## Switch between in-progress branches.
5472

5573
1. Git `add` and `commit` changes to current branch:
5674
1. `git add -A`
@@ -70,7 +88,7 @@
7088

7189
1. Repeat process as needed.
7290

73-
## Use the following to delete branches for labs which have already been graded.
91+
## Delete branches for labs which have already been graded.
7492
* NOTE: We delete the branches after they have been merged into `main` since the work has been completed and all the changes have been recorded in the `commit`s. We no longer need the branches.
7593

7694
1. Sync our local record of remote branches. This will remove local references to branches which have been deleted on remote:
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/02 Unit Converter renamed to 1 Python/labs/02 Unit Converter.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ Lab 02: Unit Converter
22
This lab will involve writing a program that allows the user to convert a number between units.
33

44
Version 1
5-
Ask the user for the number of feet, and print out the equivalent distance in meters. Hint: 1 ft is 0.3048 m. So we can get the output in meters by multiplying the input distance by 0.3048. Below is some sample input/output.
5+
Ask the user for the number of feet, and print out the equivalent distance in meters. Hint: 1 ft is 0.3048 m. So we can get the output in meters by multiplying
6+
the input distance by 0.3048. Below is some sample input/output.
67

78
> what is the distance in feet? 12
89
> 12 ft is 3.6576 m
@@ -26,16 +27,19 @@ Add support for yards, and inches.
2627
Version 4 - optional
2728
Now we'll ask the user for the distance, the starting units, and the units to convert to.
2829

29-
You can think of the values for the conversions as elements in a matrix, where the rows will be the units you're converting from, and the columns will be the units you're converting to. Along the horizontal, the values will be 1 (1 meter is 1 meter, 1 foot is 1 foot, etc).
30+
You can think of the values for the conversions as elements in a matrix, where the rows will be the units you're converting from, and the columns will be the
31+
units you're converting to. Along the horizontal, the values will be 1 (1 meter is 1 meter, 1 foot is 1 foot, etc).
3032

3133
ft mi m km
3234
ft 1 0.3048
3335
mi 1 1609.34
3436
m 1/0.3048 1/1609.34 1 1/1000
3537
km 1000 1
36-
But instead of filling out that matrix, and checking for each pair of units (if from_units == 'mi' and to_units == 'km'), we can just convert any unit to meters, then convert the distance in meters to any other unit.
38+
But instead of filling out that matrix, and checking for each pair of units (if from_units == 'mi' and to_units == 'km'), we can just convert any unit to meters,
39+
then convert the distance in meters to any other unit.
3740

38-
Furthermore you can convert them from meters by dividing a distance (in meters) by those same values used above. So first convert from the input units to meters, then convert from meters to the output units.
41+
Furthermore you can convert them from meters by dividing a distance (in meters) by those same values used above. So first convert from the input units to meters,
42+
then convert from meters to the output units.
3943

4044
Below is some sample input/output:
4145

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.
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.md

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+
]

0 commit comments

Comments
 (0)